Controllable generation system based on component syntax logical hierarchical constraints

By using a controllable generation system based on constituent syntactic logical hierarchy constraints, the problem of logical disorder in text generation of large language models is solved, and the logical consistency and style controllability are improved, making it suitable for text generation tasks in different fields.

CN120975073BActive Publication Date: 2026-02-17TIANJIN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511497430.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-17
Publication Date
2026-02-17
Estimated Expiration
2045-10-17

AI Technical Summary

Technical Problem

Large language models lack the ability to control deep sentence logic and structure during text generation, resulting in disordered generation logic, lack of causal coherence and hierarchical clarity, making it difficult to meet users' specific requirements in terms of content, style, structure, etc.

Method used

A controllable generation system based on constituent syntactic logical hierarchy constraints is adopted. By training phrase extraction, logical thought chain generation and fine-tuning sub-modules, training reference texts are constructed to fine-tune the large language model, introduce clear logical guidance, and improve the logical consistency and style controllability of the generated text.

Benefits of technology

It enables explicit control over the logical consistency and stylistic controllability of generated text, improving the logical consistency, content diversity, and adaptability of generated text to the needs of text generation tasks in different fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120975073B_ABST
    Figure CN120975073B_ABST
Patent Text Reader

Abstract

The application provides a controllable generation system based on component syntax logical hierarchical constraints, and applies to the technical field of controllable text generation. The controllable generation system comprises a large model fine-tuning module, the large model fine-tuning module comprises a training phrase extraction submodule, a training logical thinking chain generation submodule and a fine-tuning submodule; the training phrase extraction submodule is used for carrying out phrase extraction on a training input text to obtain a training phrase sequence and a training label sequence, the training phrase sequence comprises a plurality of training phrases, and the training label sequence comprises training labels corresponding to the plurality of training phrases respectively; the training logical thinking chain generation submodule is used for generating a training logical thinking chain according to the training phrase sequence and the training label sequence; and the fine-tuning submodule is used for fine-tuning a large language model by using a training reference text constructed based on prompt information and the training logical thinking chain to obtain a controllable text generation large model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of controllable text generation technology, and more specifically, to a controllable generation system based on constituent syntactic logic level constraints. Background Technology

[0002] With the development of neural network architectures based on self-attention mechanisms and large-scale pre-training techniques, large language models (LLMs) have achieved near-human-level fluency and diversity performance in various natural language generation (NLG) tasks.

[0003] However, how to enable large language models to generate text on demand while maintaining language quality—that is, meeting users' requirements in terms of content, style, tone, structure, length, and compliance—has gradually become a focus of attention. Based on this, Controllable Text Generation (CTG) technology has emerged. Controllable generation technology can be divided into three stages according to the intervention phase: control during training, control during inference or decoding, and hybrid or post-processing control.

[0004] In the process of realizing the concept of this invention, it was found that the related technologies have at least the following problems: In the process of text generation, large language models rely on learning the probability distribution of large-scale corpora, but lack the ability to control the deep sentence logic and structure. They are prone to problems such as disordered or jumping generation logic, lack of causal coherence and hierarchical clarity in specific fields or application scenarios. Summary of the Invention

[0005] In view of this, the present invention provides a controllable generation system based on constituent syntactic logic level constraints.

[0006] According to one aspect of the present invention, a controllable generation system based on constituent syntactic logic hierarchy constraints is provided. The controllable generation system includes a large model fine-tuning module, which further includes a training phrase extraction submodule, a training logic chain generation submodule, and a fine-tuning submodule. The training phrase extraction submodule is used to extract phrases from the training input text to obtain a training phrase sequence and a training label sequence, wherein the training phrase sequence includes multiple training phrases, and the training label sequence includes training labels corresponding to each of the multiple training phrases. The training logic chain generation submodule is used to generate a training logic chain based on the training phrase sequence and the training label sequence, wherein the training logic chain represents the constituent syntactic logic hierarchy of the training input text. The fine-tuning submodule is used to fine-tune the large language model using training reference text constructed based on prompt information and the training logic chain, thereby obtaining a controllable text generation large model.

[0007] According to an embodiment of the present invention, the training phrase extraction submodule includes: a training component syntax parsing unit, configured to perform component syntax parsing on the training input text to obtain a coarse-grained training structure tree, wherein the coarse-grained training structure tree includes at least two levels, each level including at least one node, the node representing the training phrases and phrase tags of the training phrases in the training input text; and a training phrase extraction unit, configured to extract phrases from the coarse-grained training structure tree according to an extraction strategy to obtain the training phrase sequence and the training tag sequence.

[0008] According to an embodiment of the present invention, the training phrase extraction unit is configured to: when the extraction strategy indicates a target granularity, extract nodes located at the target granularity level based on the hierarchical information of each node, to obtain a plurality of coarse-grained training phrases and coarse-grained training labels corresponding to each of the coarse-grained training phrases; when the extraction strategy indicates a target phrase type, extract nodes corresponding to the target phrase type from the nodes of the sub-level corresponding to the coarse-grained training phrases, to obtain a plurality of fine-grained training phrases and fine-grained training labels corresponding to each of the fine-grained training phrases; and obtain the training phrase sequence and the training label sequence according to a phrase replacement mapping constructed based on the coarse-grained training phrases, the coarse-grained training labels, the fine-grained training phrases, and the fine-grained training labels.

[0009] According to an embodiment of the present invention, the above-mentioned training logic thought chain generation submodule is used to: construct a fine-grained training structure tree based on the above-mentioned training phrase sequence and the above-mentioned training label sequence, wherein the data volume of the above-mentioned fine-grained training structure tree is less than the data volume of the coarse-grained training structure tree obtained based on the above-mentioned training input text; and, by calling the above-mentioned large language model, annotate the logical relationships between the above-mentioned multiple training phrases based on the above-mentioned fine-grained training structure tree to obtain the above-mentioned training logic thought chain, wherein the above-mentioned logical relationships include at least one of the following: causal relationship, parallel relationship, adversative relationship, and progressive relationship.

[0010] According to an embodiment of the present invention, the fine-tuning submodule is used to: concatenate the above-mentioned prompt information and the above-mentioned training logic chain to obtain the above-mentioned training reference text; and, using a lightweight fine-tuning mechanism, fine-tune the above-mentioned large language model using the above-mentioned training reference text to obtain the above-mentioned controllable text generation large model.

[0011] According to an embodiment of the present invention, the controllable generation system further includes an evaluation module: the evaluation module includes: a component syntax parsing submodule, used to perform component syntax parsing on the training output text to obtain a generated phrase sequence and a generated label sequence, wherein the generated phrase sequence includes multiple generated phrases, and the generated label sequence includes phrase labels corresponding to each of the multiple generated phrases; and a logical relation evaluation submodule, used to evaluate the logical relation between the generated phrase sequence and the generated label sequence based on a preset evaluation dimension to obtain a logical relation evaluation value, wherein the logical relation evaluation value characterizes the degree of consistency between the logical relation of the training output text and the logical relation of the training input text.

[0012] According to an embodiment of the present invention, the above-mentioned logical relationship evaluation submodule is used to: evaluate the logical relationship between the above-mentioned generated phrase sequence and the above-mentioned generated label sequence by calling multiple candidate large language models and based on the above-mentioned preset evaluation dimensions, to obtain multiple intermediate evaluation values; and to determine the above-mentioned logical relationship evaluation value based on the above-mentioned multiple intermediate evaluation values.

[0013] According to an embodiment of the present invention, the above-mentioned preset evaluation dimensions include at least one of the following: causal coherence dimension, structural rationality dimension, semantic consistency dimension, and information redundancy dimension.

[0014] According to an embodiment of the present invention, the controllable generation system further includes a controllable text reasoning module, which includes a reasoning phrase extraction submodule and a controllable text reasoning submodule. The reasoning phrase extraction submodule is used to extract phrases from the reasoning input text to obtain a reasoning phrase sequence and a reasoning tag sequence, wherein the reasoning phrase sequence includes multiple reasoning phrases, and the reasoning tag sequence includes reasoning tags corresponding to each of the multiple reasoning phrases. The controllable text reasoning submodule is used to process the reasoning reference text constructed based on the prompt information, the reasoning phrase sequence, and the reasoning tag sequence by calling the controllable text generation large model to obtain a reasoning output text, wherein the reasoning reference text represents the logical relationship between the multiple reasoning phrases.

[0015] According to an embodiment of the present invention, the aforementioned inference reference text is constructed in the following manner: When the controllable text generation model has not undergone logical chain fine-tuning, an inference logic thought chain is generated based on the aforementioned inference phrase sequence and the aforementioned inference tag sequence, and the aforementioned inference reference text is constructed based on the aforementioned prompt information and the aforementioned inference logic thought chain, wherein the aforementioned inference logic thought chain represents the logical relationship between the aforementioned plurality of inference phrases; or, when the controllable text generation model has undergone logical chain fine-tuning, a sample set is retrieved based on the aforementioned inference phrase sequence and the aforementioned inference tag sequence, and the aforementioned inference reference text is constructed based on the aforementioned prompt information and the aforementioned sample set, wherein the matching degree between each sample in the aforementioned sample set and the aforementioned inference phrase sequence and the aforementioned inference tag sequence satisfies a predetermined matching degree condition.

[0016] According to embodiments of the present invention, syntactic logic constraints are introduced through phrase extraction and logical relation construction, which provides clear logical guidance for a large-scale controllable text generation model, enabling explicit control over the generation logic of the model and helping to improve the logical consistency, content diversity, and style controllability of the generated text. Furthermore, through flexible phrase extraction and training reference text construction methods, it can adapt to text generation tasks in different domains. Attached Figure Description

[0017] The above and other objects, features and advantages of the present invention will become clearer from the following description of embodiments of the invention with reference to the accompanying drawings.

[0018] Figure 1 An example schematic diagram of a controllable generation system based on constituent syntactic logic hierarchy constraints according to an embodiment of the present invention is shown.

[0019] Figure 2 An example schematic diagram of a large model fine-tuning module according to an embodiment of the present invention is shown.

[0020] Figure 3 The illustration shows an example of the process of extracting phrases from training input text to obtain training phrase sequences and training label sequences according to an embodiment of the present invention.

[0021] Figure 4 An example schematic diagram of a prompt message according to an embodiment of the present invention is shown.

[0022] Figure 5 An example schematic diagram of an evaluation module according to an embodiment of the present invention is shown.

[0023] Figure 6 An example schematic diagram of a prompt message according to another embodiment of the present invention is shown.

[0024] Figure 7 An example schematic diagram of the fine-tuning process of a large controllable text generation model according to an embodiment of the present invention is shown.

[0025] Figure 8 An example schematic diagram of a controllable text reasoning module according to an embodiment of the present invention is shown.

[0026] Figure 9 An example schematic diagram of a controllable text generation process according to an embodiment of the present invention is shown.

[0027] Figure 10 A block diagram of an electronic device for implementing a controllable text generation method and a large-scale controllable text generation model according to an embodiment of the present invention is shown. Detailed Implementation

[0028] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the invention. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the invention for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concept of the invention.

[0029] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0030] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0031] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).

[0032] In the technical solution of this invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information) and data (including but not limited to data used for analysis, stored data, and displayed data) involved are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, invention, and application of related data all comply with relevant laws, regulations, and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse.

[0033] In one example, a controllable text generation method may include at least one of the following: a controllable generation method based on natural language instructions, a controllable generation method based on regular expression instructions, a controllable generation method based on tag-based conditions, a diffusion-based controllable generation method, and a controllable generation method for the decoding stage, etc.

[0034] Natural language instruction-based control generation methods involve automatically extracting control constraints (such as keywords, part-of-speech tags, and sentiment polarity) from natural text and converting them into natural language instructions. These instructions are then combined with training examples and input into the model to achieve controllable generation of multiple attributes. However, the supervision of this method mostly remains at the level of shallow or overall features, failing to effectively guide the model to complete generation tasks that rely on complex logical reasoning. Furthermore, the syntactic control in this method typically exists in the form of a "part-of-speech tag set," directly assigning the part-of-speech tag to each word. This approach has significant limitations in logical generation scenarios: firstly, it excessively restricts the degree of freedom in generation, resulting in unnatural or even incoherent text; secondly, it struggles to maintain consistent structural control in long text generation tasks, lacking overall logical structure modeling capabilities and making it unsuitable for tasks with high requirements for logical rationality.

[0035] Regular expression-based control-based generation methods restrict the generation process using regular expression-like text, with constraints including vocabulary, position, and length. The model learns these "rule expressions" to achieve specific output formats. However, while this method offers relatively strong structural flexibility, its control dimensions remain shallow, making it difficult to describe the logical progression and causal relationships across sentences and paragraphs in domain-specific texts. Furthermore, regular expression control is inherently template-driven, resulting in poor adaptability to diverse and structurally complex professional texts (such as legal and medical texts), especially when generating long texts with rigorous logic and consistent content.

[0036] Label-based conditional control generation methods rely on domain labels, stylistic tags, or source information as prior control signals to establish a mapping relationship between conditions and text through large-scale training or fine-tuning. However, this method has a coarse control granularity, making it difficult to achieve fine-grained control at the syntactic structure level, and its cross-domain generalization ability is limited: on the one hand, large models' understanding of "domain" or "stylistic" labels often deviates from the actual needs of users, making accurate alignment difficult; on the other hand, such methods often rely on statistical preferences in the training distribution, easily exhibiting overgeneralization or stereotypical expressions in new scenarios.

[0037] Diffusion-based control generation methods involve mapping text to a continuous noise space and generating word embedding sequences through iterative denoising to achieve gradient control over the generated content. However, while this method offers high control accuracy and can impose syntactic constraints to some extent, it suffers from computational complexity, slow inference speed, high deployment costs, and incompatibility with current mainstream large language models, limiting its widespread application in practical tasks.

[0038] Controlled generation methods for the decoding stage refer to guiding the generation direction or adjusting the generation strategy through a discriminator or hidden states to achieve control without changing the model parameters. However, this method is often used to control shallow attributes such as sentiment and theme, but its common problems are low control granularity, weak logical modeling ability, and the need for additional judgments or calculations in each generation step, which significantly affects reasoning efficiency and may even destroy the coherence and naturalness of the language.

[0039] In summary, current text generation methods suffer from several limitations during the training phase. These include shallow memorization, overfitting to the distribution of training words, and uncontrollable language bias and repetition, making it difficult to explicitly express and control the reasoning logic of generated sentences. During the reasoning phase, they lack the ability to generalize and transfer to complex structures and logical levels. Furthermore, in the post-processing phase, they cannot automatically and structurally evaluate the logical quality of the output content. Therefore, current text generation methods have limitations in logical expression, structural control, and logical evaluation of generated content, especially when facing vertical domain tasks requiring multi-layered deep logical structures, high grammatical compliance, and cross-sentence reasoning capabilities.

[0040] To address this, the present invention provides a controllable generation system based on constituent syntactic logic hierarchy constraints, applicable to the field of controllable text generation technology. This controllable generation system includes a large model fine-tuning module, which comprises a training phrase extraction submodule, a training logic chain generation submodule, and a fine-tuning submodule. The training phrase extraction submodule extracts phrases from the training input text to obtain a training phrase sequence and a training label sequence. The training phrase sequence includes multiple training phrases, and the training label sequence includes training labels corresponding to each of the multiple training phrases. The training logic chain generation submodule generates a training logic chain based on the training phrase sequence and the training label sequence. This training logic chain represents the constituent syntactic logic hierarchy of the training input text. The fine-tuning submodule fine-tunes the large language model using training reference text constructed based on prompt information and the training logic chain, resulting in a controllable text generation large model.

[0041] Figure 1 An example schematic diagram of a controllable generation system based on constituent syntactic logic hierarchy constraints according to an embodiment of the present invention is shown.

[0042] like Figure 1 As shown, the controllable generation system includes a large model fine-tuning module 200, an evaluation module 500, and a controllable text reasoning module 800.

[0043] In embodiments of the present invention, the controllable generation system consists of a complete control chain of "syntax extraction, logic injection, and output scoring" to achieve controllable generation of large language model content and automatic evaluation of generation logic. It can evaluate the structural rationality, reasoning rigor, and logic coverage of the generated content without human intervention, thereby forming a closed loop between training, generation, and evaluation.

[0044] The following sections will provide detailed explanations of the large model fine-tuning module, the evaluation module, and the controllable text reasoning module.

[0045] Figure 2 An example schematic diagram of a large model fine-tuning module according to an embodiment of the present invention is shown.

[0046] like Figure 2 As shown, the large model fine-tuning module includes a training phrase extraction submodule 210, a training logic thought chain generation submodule 220, and a fine-tuning submodule 230.

[0047] The training phrase extraction submodule 210 is used to extract phrases from the training input text to obtain a training phrase sequence and a training label sequence. The training phrase sequence includes multiple training phrases, and the training label sequence includes training labels corresponding to each of the multiple training phrases.

[0048] The training logic chain generation submodule 220 is used to generate a training logic chain based on the training phrase sequence and the training label sequence, wherein the training logic chain represents the component syntactic logic hierarchy of the training input text.

[0049] The fine-tuning submodule 230 is used to fine-tune the large language model using training reference text constructed based on prompt information and training logic chain, so as to obtain a controllable large text generation model.

[0050] Training input text refers to the original text used to generate output text in a text generation task.

[0051] Phrase extraction refers to the process of extracting phrases with specific grammatical structures or semantic meanings from training input text. The specific method of phrase extraction can be configured according to actual business needs and is not limited here. For example, a constituent parser can be used to parse the training input text to achieve phrase extraction; alternatively, a deep learning-based sequence labeling model can be used to identify and classify phrases in the training input text to achieve phrase extraction, etc. The training phrase sequence is the set of phrases obtained after phrase extraction, including multiple training phrases arranged in a certain order. The training label sequence is the sequence of grammatical types corresponding to each training phrase in the training phrase sequence, including the training labels corresponding to each training phrase.

[0052] For example, if the training input text is "A performs operation C because B breached the contract", phrases can be extracted from this training input text: noun phrase (NP) "A", prepositional phrase (PP) "because B breached the contract", and verb phrase (VP) "performed operation C". The corresponding training phrase sequence might be {"A", "because B breached the contract", "performed operation C"}, and the training label sequence might be {NP, PP, VP}.

[0053] After obtaining the training phrase sequence and training label sequence, training reference text can be constructed based on the cue information, training phrase sequence, and training label sequence. Cue information refers to auxiliary information used to guide the large-scale controllable text generation model to generate specific types of text. Training reference text refers to text used to express the logical relationships between phrases.

[0054] The method for constructing the training reference text can be configured according to actual business needs and is not limited here. For example, the prompt information, training phrase sequence, and training label sequence can be directly integrated, that is, the training phrases and their corresponding training labels can be inserted into the prompt information to obtain the training reference text representing the logical relationship of the phrases; alternatively, a template engine can be used to dynamically generate the training reference text based on predefined templates, etc.

[0055] After obtaining the training reference text, a large-scale controllable text generation model can be invoked to process the training reference text and obtain the output text. A large-scale controllable text generation model refers to a deep learning model trained on a large amount of data, capable of generating natural language output text based on the training input text. The output text refers to the final text generated by the large-scale controllable text generation model after processing the training reference text.

[0056] According to embodiments of the present invention, syntactic logic constraints are introduced through phrase extraction and logical relation construction, which provides clear logical guidance for a large-scale controllable text generation model, enabling explicit control over the generation logic of the model and helping to improve the logical consistency, content diversity, and style controllability of the generated text. Furthermore, through flexible phrase extraction and training reference text construction methods, it can adapt to text generation tasks in different domains.

[0057] The following is for reference. Figures 2-9 The controllable generation system according to embodiments of the present invention will be further described.

[0058] According to an embodiment of the present invention, the training phrase extraction submodule 210 may include a training component syntax parsing unit and a training phrase extraction unit.

[0059] The training component syntactic parsing unit is used to perform component syntactic parsing on the training input text to obtain a coarse-grained training structure tree. The coarse-grained training structure tree includes at least two levels, and each level includes at least one node. The node represents the training phrase and the phrase label of the training phrase in the training input text.

[0060] The training phrase extraction unit is used to extract phrases from the coarse-grained training structure tree according to the extraction strategy, so as to obtain the training phrase sequence and the training label sequence.

[0061] Constituent parsing can analyze the grammatical structure of training input text to identify phrases and their types, resulting in a coarse-grained training structure tree representing the grammatical hierarchy and phrase structure of the training input text. For example, using a constituent parser to parse the training input text "A performs operation C because B breached the contract" can yield a coarse-grained training structure tree including the noun phrase "A", the prepositional phrase "because B breached the contract", and the verb phrase "performed operation C".

[0062] The specific method of constituent syntactic parsing can be configured according to actual business needs and is not limited here. For example, a constituent syntactic parser can be used to analyze the training input text and generate a coarse-grained training structure tree representing its syntactic structure; alternatively, a deep learning-based neural network model can be used to perform syntactic parsing on the training input text to obtain a coarse-grained training structure tree, etc.

[0063] The coarse-grained training structure tree consists of at least two levels, which can represent the nesting relationship between various training phrases in the training input text. For example, the noun phrase "A" is at a lower level, while the training input text is at a higher level. Each level includes at least one node, which refers to each element in the coarse-grained training structure tree, representing a training phrase in the training input text and its phrase label.

[0064] The specific method for phrase extraction can be configured according to actual business needs and is not limited here. In one example, extraction can be performed based on an extraction strategy, which refers to the rules used to extract logical statement units from a coarse-grained training structure tree. This strategy may include the target granularity of the phrase and the target phrase label. The target granularity refers to the hierarchical depth of the specified phrase, used to determine the level of detail of the extracted phrase. The target phrase label refers to the specified phrase label to be extracted, which can be adapted to the domain of the text generation task. For example, a target granularity of 2 indicates the extraction of second-level phrases, and the target phrase label is a verb phrase. In another example, extraction can be combined with semantic information. For example, semantic role labeling (SRL) technology can be used to extract phrases with specific semantic roles as logical statement units.

[0065] According to embodiments of the present invention, through component syntactic parsing and logical statement unit extraction, logically meaningful phrases and their types can be accurately extracted from the training input text according to user-defined grammatical granularity or phrase tags, providing structured input for subsequent text generation or analysis tasks. This structured processing method not only improves the efficiency of text processing, but also enhances the accuracy and logic of the generated or analyzed results, and is especially suitable for natural language processing tasks with high requirements for logical rigor.

[0066] According to an embodiment of the present invention, the training phrase extraction unit is configured to: when the extraction strategy indicates a target granularity, extract nodes located at the target granularity level based on the hierarchical information of each node, to obtain multiple coarse-grained training phrases and coarse-grained training labels corresponding to each coarse-grained training phrase; when the extraction strategy indicates a target phrase type, extract nodes corresponding to the target phrase type from the nodes of the sub-level corresponding to the coarse-grained training phrases, to obtain multiple fine-grained training phrases and fine-grained training labels corresponding to each fine-grained training phrase; and obtain a training phrase sequence and a training label sequence according to a phrase replacement mapping constructed based on the coarse-grained training phrases, coarse-grained training labels, fine-grained training phrases, and fine-grained training labels.

[0067] The target granularity (i.e., grain) refers to the hierarchical depth of a specified phrase, used to determine the level of detail of the extracted phrases. Hierarchical information refers to the hierarchical position of each node in the syntax tree structure. This hierarchical information can be obtained using an objective function, for example, `get_constituent_depth(tree)`. Coarse-grained training phrases (i.e., `logic_utterance_units`) are the phrases extracted from the syntax tree structure according to the target granularity. For example, a target granularity of 2 indicates the extraction of phrases at the second level. The coarse-grained training phrases extracted from the coarse-grained training tree structure of the sentence "A performs operation C because B breached the contract" might be "because B breached the contract" and "performed operation C".

[0068] The specific method for extracting coarse-grained training phrases based on the target granularity can be configured according to actual business needs and is not limited here. For example, depth-first search (DFS) or breadth-first search (BFS) algorithms can be used to extract phrases of a specified level from the coarse-grained training structure tree as coarse-grained training phrases; alternatively, phrases of a specified target level can be directly extracted from the coarse-grained training structure tree as coarse-grained training phrases.

[0069] The target training label (i.e., `special_phrase`) refers to the specified training label to be extracted, which can be used to enhance the understanding of core information by the large text generation model. Fine-grained training phrases (i.e., `special_phrase_units`) are phrases extracted from the sub-layers (i.e., `special_phrase_grain`) of the coarse-grained training phrase based on the target training label. For example, if the target training label is a noun phrase, the fine-grained training phrase extracted from the coarse-grained training phrase "because B breached the contract" might be simply "B".

[0070] The specific method for extracting fine-grained training phrases based on the target training labels can be configured according to actual business needs and is not limited here. For example, phrases that match the target training labels can be directly extracted from the sub-levels of coarse-grained training phrases to obtain fine-grained training phrases; alternatively, rule-based pattern matching methods can be used to extract phrases that match specific patterns from the sub-levels of coarse-grained training phrases as fine-grained training phrases.

[0071] After obtaining the coarse-grained and fine-grained training phrases, a phrase substitution map can be constructed to obtain the training phrase sequence and training label sequence based on the phrase substitution map. The construction method of the phrase substitution map can be configured according to actual business needs and is not limited here. In one example, for each coarse-grained and fine-grained training phrase, a locator position can be found in the input text and replaced with a specific marker or symbol to construct a hierarchical semantic chain, thereby explicitly representing the logical nesting and combination relationships within the sentence. For example, "because B breached the contract" can be replaced with "(because B breached the contract)," and "perform operation C" can be replaced with "(perform operation C)." In another example, the extracted coarse-grained and fine-grained training phrases can be replaced with encoded information using encoding methods, such as replacing the phrases with vector representations.

[0072] According to embodiments of the present invention, through multi-level phrase extraction and replacement mapping, logically meaningful phrases and their types can be flexibly extracted from the input text, providing rich structured information for subsequent text generation or analysis tasks. This multi-level extraction method not only improves the accuracy of phrase extraction but also enhances the ability to process complex grammatical structures. It is particularly suitable for natural language processing tasks with high requirements for logical rigor, and can better adapt to the text processing needs of different fields, improving the accuracy and logic of the generated or analyzed results.

[0073] Figure 3 The illustration shows an example of the process of extracting phrases from training input text to obtain training phrase sequences and training label sequences according to an embodiment of the present invention.

[0074] like Figure 3 As shown, the training input text 301 is parsed using component syntax to obtain a coarse-grained training structure tree 302.

[0075] With the extraction strategy indicating the target granularity 303, based on the hierarchical information of each node in the coarse-grained training structure tree 302, nodes at the level of the target granularity 303 are extracted to obtain multiple coarse-grained training phrases 304_1 and coarse-grained training labels 304_2 corresponding to each coarse-grained training phrase 304_1.

[0076] If the extraction strategy also indicates the target phrase type, then nodes corresponding to the target phrase type can be extracted from the sub-level nodes corresponding to the coarse-grained training phrase 304_1 to obtain multiple fine-grained training phrases 305_1 and fine-grained training labels 305_2 corresponding to each fine-grained training phrase 305_1.

[0077] Based on this, a phrase substitution map 306 can be constructed using multiple coarse-grained training phrases 304_1, coarse-grained training labels 304_2, fine-grained training phrases 305_1, and fine-grained training labels 305_2. After obtaining the phrase substitution map 306, the training phrase sequence 307 and the training label sequence 308 can be obtained based on the phrase substitution map 306.

[0078] According to an embodiment of the present invention, the training logic thought chain generation submodule 220 can be used to: construct a fine-grained training structure tree based on a training phrase sequence and a training label sequence, wherein the data volume of the fine-grained training structure tree is smaller than the data volume of the coarse-grained training structure tree obtained based on the training input text. By calling a large language model, based on the fine-grained training structure tree, the logical relationships between multiple training phrases are labeled to obtain a training logic thought chain, wherein the logical relationships include at least one of the following: causal relationship, parallel relationship, adversative relationship, and progressive relationship.

[0079] After obtaining the training phrase sequence and training label sequence, a simplified fine-grained training structure tree can be constructed based on these sequences. The data size of the fine-grained training structure tree is smaller than that of the coarse-grained training structure tree obtained based on the training input text. For example, the coarse-grained training structure tree may contain the detailed syntactic structure of the entire training input text, while the fine-grained training structure tree contains the structural organization between key sentences.

[0080] For fine-grained training structure trees, the logical relationships between multiple training phrases can be labeled to obtain training logical thought chains. Logical relationships refer to the semantic relationships between phrases. For example, logical relationships can include at least one of the following: causal relationship, parallel relationship, adversative relationship, and progressive relationship. A causal relationship indicates that one event leads to the occurrence of another event. A parallel relationship indicates that two or more events or concepts are equal and parallel. An adversative relationship indicates that the latter event is logically contrasted with the former event. A progressive relationship indicates that the latter event is more profound or further than the former in degree or meaning. Training logical thought chains are in natural language form, for example, "Firstly..." ,then ,therefore ".

[0081] The annotation method for logical relationships can be configured according to actual business needs, and is not limited here. For example, a fine-grained training structure tree can be input into a large controllable text generation model, which will then annotate the logical relationships between phrases to generate a training logical thinking chain. Alternatively, a specially trained relationship annotation model can be used to annotate the logical relationships between phrases. Another alternative is to use the dependency parsing function in a natural language processing tool to annotate the fine-grained training structure tree. In a specific example, the construction form of the training logical thinking chain is shown in the following formula (1).

[0082] (1);

[0083] in, Representation training of logical thinking chain, Characterization prompt information, Representation training input text, Representing a fine-grained training structure tree. Labels representing logical relationships.

[0084] According to embodiments of the present invention, by constructing a simplified fine-grained training structure tree and using a controllable large-scale text generation model to annotate the logical relationships between phrases, training logical thought chains can be generated efficiently. This not only reduces the consumption of computational resources but also improves the accuracy and efficiency of logical relationship annotation. Furthermore, by explicitly annotating causal, parallel, and adversative logical relationships, this method of generating training logical thought chains provides clearer logical guidance for text generation, helping to improve the structural clarity and logical consistency of the generated content. This makes the generated text more logical and coherent, thereby improving the quality and reliability of the generated text.

[0085] Figure 4 An example schematic diagram of a prompt message according to an embodiment of the present invention is shown.

[0086] like Figure 4 As shown, the prompt information can include three parts: the first prompt part 410 is used to provide input and output, the second prompt part 420 is used to provide the statement tree structure, and the third prompt part 430 is used to provide guidance information.

[0087] For example, the first prompt, 410, indicates that "You are an expert in domain A, and your goal is to understand the logical structure of complex text in domain A. Here are the input-output pairs: [Input][Output]". [Input] refers to the text pairs in the original task, which are evaluated by the model; [Output] refers to the reasoning results in the target task, such as conclusion statements, which need to be evaluated by the language model to determine whether they can be reasonably deduced from the input.

[0088] For example, the second prompt section 420 indicates that "we obtained the following statement structure from the constituent syntax parsing: [statement tree structure]". The [statement tree structure] is the second phrase sequence and the second type sequence extracted from the output text and organized into a structured second tree structure, which is used by the model to assist in judging the rationality of the logical path.

[0089] For example, the third prompt, 430, instructs, "Based on the tree structure above, reconstruct the logical reasoning path of the input pairs. The output should clearly indicate the relationships between these statement structures, such as combination, sequence, condition, or parallelism, in order to facilitate the learning of deeper logic."

[0090] According to an embodiment of the present invention, the fine-tuning submodule 230 can be used to: concatenate the prompt information and the training logic chain to obtain the training reference text; and, using a lightweight fine-tuning mechanism, fine-tune the large language model using the training reference text to obtain a controllable large text generation model.

[0091] The second input sample text refers to the text obtained by concatenating the prompt information with the training logical thought chain, used to train the large language model. Lightweight fine-tuning mechanisms refer to methods for fine-tuning pre-trained models involving less training data and shorter training time. By using lightweight fine-tuning mechanisms for supervised training of large language models, the models can learn content generation under explicit logical constraints, suppressing shallow memory and bias, and enhancing deep thinking and generalization abilities in reasoning. For example, lightweight fine-tuning mechanisms can include at least one of the following: Low Rank Adaptation (LoRA), Prompt Tuning (P-Tuning), and Adapter-tuning.

[0092] For example, a low-order adaptation method can be used to fine-tune a large language model by adding low-rank matrices to certain layers of the model and adjusting the model parameters to make the generated text more logical and semantically consistent. Alternatively, a cue-based tuning method can be used to optimize the generated text by adjusting the model's input cue. Another alternative is an adapter fine-tuning method, which adjusts the model parameters by adding small adapter modules to the model.

[0093] According to embodiments of the present invention, by concatenating prompts with the training logic chain, more explicit training guidance is provided to the large language model, significantly improving the logicality and accuracy of the generated text. Furthermore, by employing a lightweight fine-tuning mechanism, model parameters can be optimized with less training data and a shorter training time, making the generated text more consistent with logical and semantic requirements. Thus, not only is the quality of generated text improved, but the model's adaptability and generalization ability are also enhanced, enabling it to better adapt to text generation tasks in different domains and ensuring the quality and reliability of the generated text.

[0094] Figure 5 An example schematic diagram of an evaluation module according to an embodiment of the present invention is shown.

[0095] like Figure 5 As shown, the evaluation module includes a component parsing submodule 510 and a logical relation evaluation submodule 520.

[0096] The component parsing submodule 510 is used to perform component parsing on the training output text to obtain a sequence of generated phrases and a sequence of generated labels. The sequence of generated phrases includes multiple generated phrases, and the sequence of generated labels includes phrase labels corresponding to each of the multiple generated phrases.

[0097] The logical relationship evaluation submodule 520 is used to evaluate the logical relationship between the generated phrase sequence and the generated label sequence based on a preset evaluation dimension, and obtain the logical relationship evaluation value. The logical relationship evaluation value represents the degree of consistency between the logical relationship of the training output text and the logical relationship of the training input text.

[0098] After obtaining the training output text, constituent syntactic parsing can be performed to obtain a sequence of generated phrases and a sequence of generated labels. The sequence of generated phrases includes multiple generated phrases, and the sequence of generated labels includes phrase labels corresponding to each of the generated phrases. The method for performing constituent syntactic parsing on the training output text is the same as that for performing constituent syntactic parsing on the training input text, and will not be elaborated further here.

[0099] The specific method for evaluating the logical relationship between the generated phrase sequences and generated label sequences can be configured according to actual business needs and is not limited here. For example, the generated phrase sequences and generated label sequences can be evaluated according to preset evaluation dimensions to calculate the logical relationship evaluation value; alternatively, a machine learning model can be used to train a classifier to automatically evaluate the logical relationship; alternatively, reinforcement learning methods can be used to allow the model to learn to evaluate the logical relationship through interaction with the environment, etc.

[0100] Pre-defined evaluation dimensions are standard dimensions used to measure the rationality and coherence of logical relationships within a text, as well as the overall quality of the text. For example, pre-defined evaluation dimensions may include at least one of the following: causal coherence, structural rationality, semantic consistency, and information redundancy. The causal coherence dimension assesses whether the causal relationships in the text are clear and logically coherent. The structural rationality dimension assesses whether the overall structure of the text is complete and organized. The semantic consistency dimension assesses whether the words, phrases, and sentences in the text are semantically consistent and free from contradictions. The information redundancy dimension assesses whether there is unnecessary repetition of information in the text.

[0101] It should be noted that, depending on the specific task requirements or the domain, one or more pre-defined evaluation dimensions can be selected to measure the quality of the training output text. For example, the output can be evaluated to determine whether it accurately captures the factual logic and core semantics of the input; whether the syntactic structure clearly reflects the main cause, parallel causes, and conclusion; and whether there are logical jumps, structural inconsistencies, or inappropriate inferences.

[0102] For the process of evaluating logical relationships based on various preset evaluation dimensions, each preset evaluation dimension can be assigned the same weight, and the logical relationship evaluation value can be determined according to the sub-evaluation value corresponding to each preset evaluation dimension. Alternatively, the weight of each preset evaluation dimension can be dynamically adjusted based on user feedback data to determine the logical relationship evaluation value. For example, if users frequently object to the logical coherence of a certain text generation result, the weight of the causal coherence dimension in the overall evaluation can be increased.

[0103] The logical relation evaluation score characterizes the degree to which the logical relations in the training output text match the logical relations in the training input text. For example, a logical relation evaluation score of 85 might indicate that the logical relations between the training output text and the training input text are relatively consistent. The logical relation evaluation score can be used to filter the training output text to further meet tasks with high requirements for logical rigor.

[0104] According to embodiments of the present invention, by using constituent syntactic parsing and multi-dimensional logical relationship evaluation, not only is the evaluation accuracy of text generation quality improved, but clear feedback is also provided for the optimization of the text generation model, enabling precise measurement of the logic and coherence of the generated text. Through this quantitative evaluation of logical relationships, the text generation model can be better adjusted and improved, making the generated text more consistent with logical and semantic requirements. This is particularly suitable for natural language processing tasks with high requirements for logical rigor, ensuring the interpretability and controllability of the generated text's logic.

[0105] According to an embodiment of the present invention, the logical relationship evaluation submodule can be used to: evaluate the logical relationship between the generated phrase sequence and the generated label sequence by calling multiple candidate large language models based on a preset evaluation dimension, and obtain multiple intermediate evaluation values; and determine the logical relationship evaluation value based on the multiple intermediate evaluation values.

[0106] In the process of evaluating logical relationships based on preset evaluation dimensions, multiple candidate large language models can be invoked to determine intermediate evaluation values, and then these intermediate evaluation values ​​can be integrated to obtain the logical relationship evaluation value. The intermediate evaluation value refers to the value obtained by each candidate large language model after evaluating the generated phrase sequence and the generated label sequence according to the evaluation dimensions.

[0107] In one example, each candidate large language model can be used to evaluate each preset evaluation dimension separately, meaning there is a one-to-one correspondence between the candidate large language model and the preset evaluation dimensions. In this case, the intermediate evaluation value of each candidate large language model is the evaluation value corresponding to the preset evaluation dimension for which that candidate large language model is used.

[0108] For example, candidate large language model 1 is used to evaluate the causal coherence dimension, obtaining a causal coherence evaluation value; candidate large language model 2 is used to evaluate the structural rationality dimension, obtaining a structural rationality evaluation value; candidate large language model 3 is used to evaluate the semantic consistency dimension, obtaining a semantic consistency evaluation value; and candidate large language model 4 is used to evaluate the information redundancy dimension, obtaining an information redundancy evaluation value. These causal coherence evaluation values, structural rationality evaluation values, semantic consistency evaluation values, and information redundancy evaluation values ​​are the intermediate evaluation values.

[0109] In another example, each candidate large language model can be used to evaluate all preset evaluation dimensions, meaning there is a many-to-many correspondence between the candidate large language model and the preset evaluation dimensions. In this case, the intermediate evaluation value of each candidate large language model is the sub-evaluation value for each preset evaluation dimension.

[0110] For example, candidate large language model 1 is used to evaluate the causal coherence, structural rationality, semantic consistency, and information redundancy dimensions, yielding a causal coherence evaluation value of 1, a structural rationality evaluation value of 1, a semantic consistency evaluation value of 1, and an information redundancy evaluation value of 1. Candidate large language model 2 is used to evaluate the causal coherence, structural rationality, semantic consistency, and information redundancy dimensions, yielding a causal coherence evaluation value of 2, a structural rationality evaluation value of 2, a semantic consistency evaluation value of 2, and an information redundancy evaluation value of 2. The aforementioned causal coherence evaluation value 1 to information redundancy evaluation value 1 and causal coherence evaluation value 2 to information redundancy evaluation value 2 are the intermediate evaluation values.

[0111] For each intermediate evaluation value, multiple intermediate evaluation values ​​can be combined to obtain the final logical relationship evaluation value. For example, a weighted average of the intermediate evaluation values ​​can be applied, or the highest score can be selected as the final evaluation value. If the Generative Pre-Trained Transformer (GPT) gives a score of 80 and the Bidirectional Encoder Representations from Transformers (BERT) gives a score of 90, the final evaluation value could be 85. Alternatively, machine learning methods can be used, such as training a regression model to combine multiple intermediate evaluation values. For example, a random forest regression model can be used to learn how to combine intermediate evaluation values ​​based on historical evaluation data to obtain a more accurate logical relationship evaluation value.

[0112] According to embodiments of the present invention, the accuracy and reliability of logical relationship evaluation are improved through collaborative evaluation of multiple candidate large language models. Each model evaluates the logical relationships of the output text from different perspectives, generating multiple intermediate evaluation values. These values ​​are then comprehensively processed to obtain the final logical relationship evaluation value. This not only fully utilizes the advantages of different models but also reduces the bias that a single model might introduce through multi-model evaluation. As a result, the final logical relationship evaluation value can more comprehensively reflect the logical consistency between the output text and the input text, thereby improving the quality and reliability of the generated text.

[0113] Figure 6 An example schematic diagram of a prompt message according to another embodiment of the present invention is shown.

[0114] like Figure 6 As shown, the prompts are used to guide the large language model in scoring the logical rigor and structural rationality of the generated sentences. The prompts can include three parts: the fourth prompt part 610 provides input and output, the fifth prompt part 620 provides the sentence tree structure, and the sixth prompt part 630 provides guidance information.

[0115] For example, the fourth prompt section 610 indicates "You are an expert in domain A, and your goal is to score complex text in domain A. Here is the input-output pair: [Input][Output]".

[0116] For example, the fifth prompt section 620 indicates that "for the output statement, the following statement structure is obtained from the constituent syntax parsing: [statement tree structure]".

[0117] For example, the sixth prompt, 630, instructs: "Based on the syntactic structure, and in conjunction with the facts and semantics in the input, evaluate the logical rationality and causal inference quality of the model's output. Consider the following aspects: whether the output accurately captures the factual logic and core semantics in the input; whether the syntactic structure clearly reflects the main cause, parallel causes, and conclusion; whether there are logical jumps, structural confusion, or inappropriate inferences. Please give a score after comprehensive judgment, with a full score of 100. Write your score in [ ]." The sixth prompt, 630, guides the large language model to comprehensively judge from dimensions such as semantic consistency, causal order, and syntactic structure, and output a score from 0 to 100. This allows for automatic evaluation and reinforcement of logical control capabilities during the generation process, achieving a closed loop of generation and evaluation.

[0118] Figure 7 An example schematic diagram of the fine-tuning process of a large controllable text generation model according to an embodiment of the present invention is shown.

[0119] like Figure 7 As shown, the training input text 702 is parsed using component syntax to obtain a coarse-grained training structure tree 703. For example, the training input text 702 is “C believes that…”. According to the extraction strategy, phrases are extracted from the coarse-grained training structure tree 703 to obtain a training phrase sequence and a training label sequence. By calling the large language model 720, a training reference text 704 is constructed based on the first prompt information 701, the training phrase sequence, and the training label sequence. For example, the first prompt information 701 is “You are a B-domain expert, generating inference based on the following content…”, and the training reference text 704 is “C believes that IP(IP1(PP,NP,VP),IP2,IP3)… The inference part contains three clauses: IP1 is the main cause (containing grammatical components PP,NP,VP), IP2 is a parallel secondary cause, and IP3 is the result…”. The first prompt information 701 and the training reference text 704 are input into the large language model 720 to obtain the training output text 730. For example, the training output text 730 is “C believes that…”.

[0120] The training output text 730 is parsed using component syntax to obtain a fine-grained training structure tree 705. Based on the extraction strategy, phrases are extracted from the fine-grained training structure tree 705 to obtain another training phrase sequence and another training label sequence. By calling the large language model 720, and based on a preset evaluation dimension, the logical relationship between this other training phrase sequence and the other training label sequence is evaluated, resulting in a first logical relationship evaluation value 740.

[0121] Based on the first logical relation evaluation value 740 of each training output text 730, high-quality generated texts are selected from the training output texts 730 and used as the output training target texts 750 to guide the large language model 720 to perform fine-tuning, thus obtaining a controllable text generation large model.

[0122] Figure 8 An example schematic diagram of a controllable text reasoning module according to an embodiment of the present invention is shown.

[0123] like Figure 8 As shown, the controllable text reasoning module includes a reasoning phrase extraction submodule 810 and a controllable text reasoning submodule 820.

[0124] The inference phrase extraction submodule 810 is used to extract phrases from the inference input text to obtain an inference phrase sequence and an inference tag sequence. The inference phrase sequence includes multiple inference phrases, and the inference tag sequence includes inference tags corresponding to each of the multiple inference phrases.

[0125] The controllable text reasoning submodule 820 is used to process the reasoning reference text constructed based on prompt information, reasoning phrase sequence and reasoning label sequence by calling the controllable text generation large model to obtain the reasoning output text, wherein the reasoning reference text represents the logical relationship between multiple reasoning phrases.

[0126] Inference input text refers to the original text used in the text generation task to generate inference output text.

[0127] Phrase extraction refers to the process of extracting phrases with specific grammatical structures or semantic meanings from inference input text. The specific method of phrase extraction can be configured according to actual business needs and is not limited here. For example, a constituent parser can be used to parse the inference input text to achieve phrase extraction; alternatively, a deep learning-based sequence labeling model can be used to identify and classify phrases in the inference input text to achieve phrase extraction, etc. The inference phrase sequence is the set of phrases obtained after phrase extraction, including multiple inference phrases arranged in a certain order. The inference label sequence is the sequence of grammatical types corresponding to each inference phrase in the inference phrase sequence, including the inference labels corresponding to each inference phrase.

[0128] For example, if the inference input text is "A performs operation C because B breaches the contract", phrase extraction can be performed from this inference input text to obtain the noun phrase (NP) "A", the prepositional phrase (PP) "because B breaches the contract", and the verb phrase (VP) "perform operation C". The corresponding inference phrase sequence may be {"A", "because B breaches the contract", "perform operation C"}, and the inference label sequence may be {NP, PP, VP}.

[0129] After obtaining the inference phrase sequence and inference label sequence, inference reference text can be constructed based on the cue information, inference phrase sequence, and inference label sequence. Cue information refers to auxiliary information used to guide the large-scale controllable text generation model to generate specific types of text. Inference reference text refers to text used to express the logical relationships between phrases.

[0130] The method for constructing the inference reference text can be configured according to actual business needs and is not limited here. For example, the prompt information, inference phrase sequence, and inference tag sequence can be directly integrated, that is, the inference phrase and its corresponding inference tag are inserted into the prompt information to obtain the inference reference text representing the logical relationship of the phrases; alternatively, a template engine can be used to dynamically generate the inference reference text based on predefined templates, etc.

[0131] After obtaining the inference reference text, a large-scale controllable text generation model can be invoked to process it and obtain the inference output text. The large-scale controllable text generation model refers to a deep learning model trained on a large amount of data, capable of generating natural language inference output text based on the inference input text. The inference output text refers to the final text generated by the large-scale controllable text generation model after processing the inference reference text.

[0132] It should be noted that the text generation method provided in this embodiment of the invention has universality and can also be applied to downstream tasks in natural language processing that require high logical rigor. For example, the text generation method can be applied to the legal, medical, and financial fields.

[0133] According to embodiments of the present invention, syntactic logic constraints are introduced through phrase extraction and logical relation construction, which can provide clear logical guidance for large-scale text generation models, enabling explicit control over the generation logic of large-scale text generation models. This helps improve the logical consistency, content diversity, and style controllability of generated text. Furthermore, through flexible phrase extraction and reference text construction methods, it can adapt to text generation tasks in different domains.

[0134] According to embodiments of the present invention, the inference reference text can be constructed in the following ways: In the case where the controllable text generation model has not undergone logical chain fine-tuning, an inference logic thought chain is generated based on the inference phrase sequence and the inference tag sequence, and an inference reference text is constructed based on the prompt information and the inference logic thought chain, wherein the inference logic thought chain represents the logical relationship between multiple inference phrases; or, in the case where the controllable text generation model has undergone logical chain fine-tuning, a sample set is retrieved based on the inference phrase sequence and the inference tag sequence, and an inference reference text is constructed based on the prompt information and the sample set, wherein the matching degree between each sample in the sample set and the inference phrase sequence and the inference tag sequence satisfies a predetermined matching degree condition.

[0135] For the structural and logical control generation of large-scale controllable text generation models in scenarios with no training samples or low resources, different methods for constructing inference reference texts can be selected based on whether the large-scale controllable text generation model has undergone logic chain fine-tuning. Logic chain fine-tuning refers to the process of training the large-scale controllable text generation model to generate text that conforms to logical relationships. When the large-scale controllable text generation model has not undergone logic chain fine-tuning, a method of generating inference logic chains and using these chains to construct inference reference texts can be adopted. When the large-scale controllable text generation model has undergone logic chain fine-tuning, a method of retrieving sample sets and using them to construct inference reference texts can be adopted to improve generation quality and stability.

[0136] Reasoning logic chains represent the logical relationships between multiple reasoning phrases, guiding the model to generate logically consistent text. For example, "First, the plaintiff (NP), then, due to the defendant's breach of contract (PP), therefore, a lawsuit was filed (VP)." When using reasoning logic chains to construct reasoning reference text, the reasoning logic chains can be directly inserted into prompts; alternatively, a template engine can be used to dynamically generate reasoning reference text based on predefined templates, improving flexibility.

[0137] The example set refers to pre-labeled text examples used to provide logical guidance when the model has not undergone fine-tuning of the logic chain. The example set can be obtained by dynamically retrieving the most relevant examples to the inference input text from a large amount of text using a retrieval-based reinforcement learning method. The process of constructing the inference reference text based on the example set is shown in the following formula (2).

[0138] (2);

[0139] in, Representational reasoning logical thought chain, Representational reasoning outputs text. The i-th example of verbal logic has been labeled in the representation example set. The prompt information in the i-th sample is represented. The inference input text representing the i-th sample is... The logical reasoning chain corresponding to the inference input text in the i-th sample is represented. Characterization prompt information, Representation utilizes large language models for text generation.

[0140] The matching degree between each example in the example set and the inference phrase sequence and inference label sequence meets a predetermined matching degree condition. The predetermined matching degree condition is a standard used to evaluate the similarity or relevance between the example and the inference input text. For example, it is required that the similarity between the example and the inference input text is greater than 80% in terms of phrase type and logical structure.

[0141] According to embodiments of the present invention, depending on whether the controllable text generation model has undergone logical chain fine-tuning, a logical guidance method based on the reasoning logical thinking chain or sample set is selected. During the reasoning stage, a small number of logical structure samples or constraint hints are used to achieve unsupervised logical guidance of the large model. This not only improves the logic and accuracy of the generated text, but also enhances the adaptability of the model under different training states. It can ensure that the generated text conforms to the logical structure of the reasoning input text, thereby improving the quality and reliability of the generated text.

[0142] Figure 9 An example schematic diagram of a controllable text generation process according to an embodiment of the present invention is shown.

[0143] like Figure 9 As shown, the inference input text 902 is parsed using component syntax to obtain a coarse-grained inference structure tree 903. For example, the inference input text 902 is “C believes that…”. According to the extraction strategy, phrases are extracted from the coarse-grained inference structure tree 903 to obtain a coarse-grained inference phrase sequence and a coarse-grained inference label sequence. By calling the controllable text generation model 920, based on the second prompt information 901, the coarse-grained inference phrase sequence, and the coarse-grained inference label sequence, an inference reference text 904 is constructed. For example, the second prompt information 901 is “You are a B domain expert, generate inference based on the following content…”, and the inference reference text 904 is “C believes that IP(IP1(PP,NP,VP),IP2,IP3)…”. The inference part contains three clauses: IP1 is the main cause (containing grammatical components PP,NP,VP), IP2 is a parallel secondary cause, and IP3 is the result…. The second prompt message 901 and the reasoning reference text 904 are output to the controllable text generation model 920 to obtain the reasoning output text 930. For example, the reasoning output text 930 is "C believes that...".

[0144] The output text 930 is parsed using component syntax to obtain a fine-grained inference structure tree 905. Based on the extraction strategy, phrases are extracted from the fine-grained inference structure tree 905 to obtain a fine-grained inference phrase sequence and a fine-grained inference label sequence. By calling the controllable text generation model 920, and based on a preset evaluation dimension, the logical relationships of the fine-grained inference phrase sequence and the fine-grained inference label sequence are evaluated to obtain a second logical relationship evaluation value 940.

[0145] Based on the second logical relation evaluation value 940 of each inference output text 930, low-quality generation is selected from the inference output text 930 and sent to the controllable text generation large model 920 for re-inference; high-quality generation is selected as the output inference target text 950, realizing generation quality control and optimization feedback in a closed loop.

[0146] This invention also provides a method for fine-tuning a large-scale controllable text generation model. This method includes: extracting phrases from the training input text to obtain a training phrase sequence and a training label sequence, wherein the training phrase sequence includes multiple training phrases, and the training label sequence includes training labels corresponding to each of the multiple training phrases; generating a training logical thought chain based on the training phrase sequence and the training label sequence, wherein the training logical thought chain represents the component syntactic logical hierarchy of the training input text; and fine-tuning the large language model using training reference text constructed based on prompt information and the training logical thought chain to obtain the large-scale controllable text generation model.

[0147] The above are merely exemplary embodiments, but are not limited thereto. Other fine-tuning methods for large controllable text generation models known in the art may also be included, as long as they can enhance the generalization ability of the model and enable it to better adapt to text generation tasks in different domains.

[0148] The present invention also provides a controllable text generation method, which includes: extracting phrases from the inference input text to obtain an inference phrase sequence and an inference tag sequence, wherein the inference phrase sequence includes multiple inference phrases and the inference tag sequence includes inference tags corresponding to each of the multiple inference phrases; and processing the inference reference text constructed based on the prompt information, the inference phrase sequence, and the inference tag sequence by calling a large-scale controllable text generation model to obtain an inference output text, wherein the inference reference text represents the logical relationship between the multiple inference phrases.

[0149] The above are merely exemplary embodiments, but are not limited thereto. Other controllable text generation methods known in the art may also be included, as long as they can improve the logical consistency, content diversity, and style controllability of the generated text.

[0150] Figure 10A block diagram of an electronic device for implementing a controllable text generation method and a large-scale controllable text generation model according to an embodiment of the present invention is shown. Figure 10 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of the present invention.

[0151] like Figure 10 As shown, a computer electronic device according to an embodiment of the present invention includes a processor 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage portion 1008 into a random access memory (RAM) 1003. The processor 1001 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1001 may also include onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0152] RAM 1003 stores various programs and data required for the operation of the electronic device. Processor 1001, ROM 1002 and RAM 1003 are interconnected via bus 1004.

[0153] According to embodiments of the present invention, the electronic device may further include an input / output (I / O) interface 1005, which is also connected to a bus 1004. The electronic device may also include one or more of the following components connected to the input / output (I / O) interface 1005: an input section 1006 including a keyboard, mouse, etc.; an output section 1007 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the input / output (I / O) interface 1005 as needed. A removable medium 1011, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 1010 as needed so that computer programs read from it can be installed into the storage section 1008 as needed.

[0154] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the fine-tuning method for a large controllable text generation model and the controllable text generation method according to embodiments of the present invention.

[0155] In this invention, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0156] Embodiments of the present invention also include a computer program product, which includes a computer program containing program code for executing the methods provided in the embodiments of the present invention. When the computer program product is run on an electronic device, the program code is used to enable the electronic device to implement the training method of the controllable text generation large model and the controllable text generation method provided in the embodiments of the present invention.

[0157] When the computer program is executed by the processor 1001, it performs the functions defined in the system / apparatus of this embodiment of the invention. According to embodiments of the invention, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0158] According to embodiments of the present invention, program code for executing the computer programs provided in the embodiments of the present invention can be written in any combination of one or more programming languages.

[0159] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. It should also be noted that in some alternative implementations, the functions indicated in the boxes may occur in a different order than those shown in the drawings.

[0160] The embodiments of the present invention have been described above. However, these embodiments are merely illustrative and not intended to limit the scope of the invention. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of the invention is defined by the appended embodiments and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of the invention, and all such substitutions and modifications should fall within the scope of the invention.

Claims

1. A controllable generation system based on constituent syntactic logic level constraints, characterized in that, The controllable generation system includes a large model fine-tuning module, which includes a training phrase extraction submodule, a training logical thinking chain generation submodule, and a fine-tuning submodule. The training phrase extraction submodule is used to extract phrases from the training input text to obtain a training phrase sequence and a training label sequence. The training phrase sequence includes multiple training phrases, and the training label sequence includes training labels corresponding to each of the multiple training phrases. The training logic thought chain generation submodule is used to generate a training logic thought chain based on the training phrase sequence and the training label sequence, wherein the training logic thought chain represents the componential syntactic logic hierarchy of the training input text; and The fine-tuning submodule is used to fine-tune the large language model using training reference text constructed based on prompt information and the training logic chain, so as to obtain a controllable large text generation model. The training phrase extraction submodule includes: A component parsing unit is trained to perform component parsing on the training input text to obtain a coarse-grained training structure tree. The coarse-grained training structure tree includes at least two levels, and each level includes at least one node. Each node represents a training phrase in the training input text and a phrase tag for that training phrase. The training phrase extraction unit is used to extract phrases from the coarse-grained training structure tree according to the extraction strategy, so as to obtain the training phrase sequence and the training label sequence. The training phrase extraction unit is used for: When the extraction strategy indicates the target granularity, based on the hierarchical information of each node, nodes located at the level of the target granularity are extracted to obtain multiple coarse-grained training phrases and coarse-grained training labels corresponding to each coarse-grained training phrase. When the extraction strategy indicates a target phrase type, nodes corresponding to the target phrase type are extracted from the sub-level nodes corresponding to the coarse-grained training phrases, resulting in multiple fine-grained training phrases and fine-grained training labels corresponding to each fine-grained training phrase; and The training phrase sequence and the training label sequence are obtained based on the phrase replacement mapping constructed from the coarse-grained training phrase, the coarse-grained training label, the fine-grained training phrase, and the fine-grained training label.

2. The controllable generation system according to claim 1, characterized in that, The training logic thinking chain generation submodule is used for: A fine-grained training structure tree is constructed based on the training phrase sequence and the training label sequence, wherein the data size of the fine-grained training structure tree is smaller than the data size of the coarse-grained training structure tree obtained based on the training input text; and By calling the large language model and based on the fine-grained training structure tree, the logical relationships between the multiple training phrases are labeled to obtain the training logical thought chain, wherein the logical relationship includes at least one of the following: causal relationship, parallel relationship, adversative relationship, and progressive relationship.

3. The controllable generation system according to claim 1, characterized in that, The fine-tuning submodule is used for: The prompt information and the training logic chain are concatenated to obtain the training reference text; as well as A lightweight fine-tuning mechanism is adopted, and the large language model is fine-tuned using the training reference text to obtain the controllable text generation large model.

4. The controllable generation system according to claim 1, characterized in that, The controllable generation system also includes an evaluation module: The evaluation module includes: A component parsing submodule is used to perform component parsing on the training output text to obtain a generated phrase sequence and a generated label sequence. The generated phrase sequence includes multiple generated phrases, and the generated label sequence includes phrase labels corresponding to each of the multiple generated phrases. The logical relationship evaluation submodule is used to evaluate the logical relationship between the generated phrase sequence and the generated label sequence based on a preset evaluation dimension, and obtain a logical relationship evaluation value, wherein the logical relationship evaluation value characterizes the degree of consistency between the logical relationship of the training output text and the logical relationship of the training input text.

5. The controllable generation system according to claim 4, characterized in that, The logical relationship evaluation submodule is used for: By calling multiple candidate large language models, and based on the preset evaluation dimension, the logical relationship between the generated phrase sequence and the generated label sequence is evaluated to obtain multiple intermediate evaluation values; as well as The logical relationship evaluation value is determined based on the multiple intermediate evaluation values.

6. The controllable generation system according to claim 4, characterized in that, The preset evaluation dimensions include at least one of the following: causal coherence dimension, structural rationality dimension, semantic consistency dimension, and information redundancy dimension.

7. The controllable generation system according to any one of claims 1 to 6, characterized in that, The controllable generation system also includes a controllable text reasoning module, which includes a reasoning phrase extraction submodule and a controllable text reasoning submodule. The inference phrase extraction submodule is used to extract phrases from the inference input text to obtain an inference phrase sequence and an inference tag sequence, wherein the inference phrase sequence includes multiple inference phrases, and the inference tag sequence includes inference tags corresponding to each of the multiple inference phrases; and The controllable text reasoning submodule is used to process the reasoning reference text constructed based on the prompt information, the reasoning phrase sequence, and the reasoning tag sequence by calling the controllable text generation large model to obtain the reasoning output text, wherein the reasoning reference text represents the logical relationship between the multiple reasoning phrases.

8. The controllable generation system according to claim 7, characterized in that, The inference reference text was constructed in the following way: Without fine-tuning the logic chain, the controllable text generation model generates a logical reasoning chain based on the inference phrase sequence and the inference tag sequence, and constructs the inference reference text based on the prompt information and the logical reasoning chain, wherein the logical reasoning chain represents the logical relationship between the multiple inference phrases; or With the controllable text generation model having undergone logical chain fine-tuning, a sample set is retrieved based on the inference phrase sequence and the inference tag sequence. The inference reference text is then constructed based on the prompt information and the sample set, wherein the matching degree between each sample in the sample set and the inference phrase sequence and the inference tag sequence satisfies a predetermined matching degree condition.

Citation Information

Patent Citations

  • Large language model instruction optimization method based on constraint perception self-learning reasoning

    CN120654834A

  • Natural language generation, a hybrid sequence-to-sequence approach

    US20170358295A1