Document generation method and device, equipment and medium
By combining semantic clustering and structural induction techniques with slot awareness mechanisms, and utilizing methods such as BERT models and HDBSCAN clustering, structured and standardized operational rule paradigms and execution plans are automatically generated. This solves the problems of low efficiency and poor accuracy in automatic generation within the enterprise's internal control system, and achieves efficient and controllable operational rule generation.
Patent Information
- Application Number
- CN202511467940.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-14
- Publication Date
- 2026-02-10
AI Technical Summary
In enterprise internal control systems with highly compliant processes and strong information isolation, existing technologies struggle to efficiently and automatically generate structured and standardized operational rule paradigms and execution plans, and suffer from problems such as a lack of training samples, high risk of semantic misinterpretation, and structural instability.
By employing semantic clustering and structural induction techniques, combined with a slot awareness mechanism, and using the BERT model for semantic vectorization, HDBSCAN clustering, syntactic dependency analysis, and the longest common subsequence algorithm, operational rule paradigms and execution schemes are automatically generated, ensuring content controllability, structural stability, and semantic accuracy.
It enables the structured expression and automatic generation of operational knowledge in scenarios with small sample sizes, high compliance requirements, and strong business interpretability requirements, thereby improving the efficiency and accuracy of generating operational rule paradigms and execution plans.
Smart Images

Figure CN121503452A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a document generation method, apparatus, device, and medium. Background Technology
[0002] In corporate internal control systems with highly compliant processes and strong information isolation, especially in industries such as finance, telecommunications, and energy, the formulation of operational rule paradigms and the construction of implementation plans have long relied on individual expert experience and manual compilation. Summary of the Invention
[0003] This application provides a document generation method, apparatus, device, and medium to automatically generate corresponding structured and standardized target documents from input text (such as operational documents), thereby improving the efficiency of target document generation, particularly the efficiency of formulating operational rule paradigms and constructing execution plans.
[0004] This application provides a document generation method, including: Obtain the input text of the target document to be generated, and determine the semantic vector of the input text; Based on the semantic vector of the input text, semantic scene classification is performed to determine the semantic cluster corresponding to the input text; Based on the semantic cluster corresponding to the input text, the correspondence between the pre-set semantic cluster and the template used to generate the target document is found, and the template corresponding to the input text is determined, wherein the template corresponding to the input text includes at least one slot with an undetermined value; For each slot: calculate the correlation between the slot and each token in the input text, and based on the correlation, determine the optimal slot value from a pre-set slot dictionary, and fill the slot with the optimal slot value as the value of the slot; Based on the template corresponding to the input text and the value of each slot in the template corresponding to the input text, the target document corresponding to the input text is generated.
[0005] As can be seen, the document generation method provided in this application can be applied to the structured and standardized automatic generation of operational documents. When the input text of the target document to be generated is obtained, the semantic vector of the input text is determined; and then, based on the semantic vector of the input text, semantic scene classification is performed to determine the semantic cluster corresponding to the input text; thereby, based on the semantic cluster corresponding to the input text, the correspondence between the pre-set semantic cluster and the template used to generate the target document can be found, and the template corresponding to the input text can be determined, wherein the template corresponding to the input text includes at least one slot with an undetermined value; and further, for each slot: the correlation between the slot and each token in the input text is calculated, and based on the correlation, the optimal slot value is determined from the pre-set slot dictionary, and the value is filled into the slot; finally, the target document corresponding to the input text can be generated based on the template corresponding to the input text and the value of each slot in the template corresponding to the input text. Therefore, the method in this application realizes the automatic generation of corresponding structured and standardized target documents for input text (e.g., operational documents), improving the efficiency of target document generation, especially the efficiency of formulating operational rule paradigms and constructing execution plans.
[0006] In some implementations, determining the semantic vector of the input text includes: The input text is fed into the BERT model, and the BERT model outputs the semantic vector of the input text.
[0007] In some implementations, the semantic vector of the input text is output through the BERT model, including: Determine the text sequence of the input text; The text sequence is decomposed into a sub-word sequence using a word segmenter; Each of the sub-words is mapped to a word vector to obtain the set of word vectors corresponding to the text sequence of the input text; The word vector set is passed through multiple Transformer encoding layers to perform contextual semantic modeling, and finally the semantic vector of the input text is obtained.
[0008] In some embodiments, the method further includes: The semantic vector of the input text is weighted and averaged to determine the overall vector of the input text.
[0009] In some implementations, semantic scene classification is performed based on the semantic vector of the input text to determine the semantic cluster corresponding to the input text, including: Based on the semantic vectors of the input text, the core distance between semantic vectors is calculated after dimensionality reduction using PCA. Based on the core distance between the semantic vectors, the density reachable distance between the semantic vectors is calculated. Based on the density reachability distance between the semantic vectors, the semantic cluster corresponding to the input text is determined by cluster stability scoring.
[0010] In some implementations, the correspondence between semantic clusters and templates used to generate target documents is pre-defined in the following manner: For the text within the semantic cluster corresponding to the input sample, the text structure and inter-word relationships are identified through syntactic dependency analysis and semantic role labeling to obtain a semantic tree; A preset algorithm is used to extract the template skeleton from the semantic tree, and variable fields are labeled as slots to obtain the template corresponding to the semantic cluster for generating the target document.
[0011] In some implementations, the preset algorithm is the Longest Common Subsequence (LCS) algorithm.
[0012] In some implementations, for each slot: calculating the relevance of the slot to each token in the input text, and determining the optimal slot value from a pre-set slot dictionary based on the relevance, including: For each of the aforementioned slots: Based on the historical values of the slot, determine the embedding vector corresponding to the slot; and determine the expression vector of each token in the input text. Calculate the relevance weight between the embedding vector of the slot and the expression vector of each token in the input text; Based on the aforementioned relevance weights, the overall expression vector of the slot is determined by weighted averaging. From the pre-set slot dictionary, select the value with the highest similarity to the overall representation vector of the slot, and determine it as the best slot value to be filled in the slot.
[0013] In some embodiments, the method further includes: Update the template, and / or update the slot dictionary.
[0014] This application provides a document generation apparatus, comprising: A semantic vector unit is used to acquire the input text of the target document to be generated and to determine the semantic vector of the input text; The classification unit is used to perform semantic scene classification based on the semantic vector of the input text and determine the semantic cluster corresponding to the input text; The template determination unit is used to find the correspondence between the pre-set semantic cluster and the template used to generate the target document based on the semantic cluster corresponding to the input text, and determine the template corresponding to the input text, wherein the template corresponding to the input text includes at least one slot with an undetermined value; The slot value determination unit is used for each slot to: calculate the correlation between the slot and each token in the input text, and based on the correlation, determine the optimal slot value from a pre-set slot dictionary, and fill the slot with the optimal slot value as the value of the slot; The generation unit is used to generate a target document corresponding to the input text based on the template corresponding to the input text and the value of each slot in the template corresponding to the input text.
[0015] In some implementations, the semantic vector unit determines the semantic vector of the input text in the following manner: Determine the text sequence of the input text; The text sequence is decomposed into a sub-word sequence using a word segmenter; Each of the sub-words is mapped to a word vector to obtain the set of word vectors corresponding to the text sequence of the input text; The word vector set is passed through multiple Transformer encoding layers to perform contextual semantic modeling, and finally the semantic vector of the input text is obtained.
[0016] In some embodiments, the slot value determination unit is specifically used for: For each of the aforementioned slots: Based on the historical values of the slot, determine the embedding vector corresponding to the slot; and determine the expression vector of each token in the input text. Calculate the relevance weight between the embedding vector of the slot and the expression vector of each token in the input text; Based on the aforementioned relevance weights, the overall expression vector of the slot is determined by weighted averaging. From the pre-set slot dictionary, select the value with the highest similarity to the overall representation vector of the slot, and determine it as the best slot value to be filled in the slot.
[0017] In some embodiments, the apparatus further includes: An update unit is used to update the template and / or update the slot dictionary.
[0018] Another embodiment of this application provides an electronic device including a memory and a processor, wherein the memory is used to store program instructions, and the processor is used to call the program instructions stored in the memory and execute any of the methods described above according to the obtained program.
[0019] Another embodiment of this application provides a computer-readable storage medium storing computer-executable instructions for causing the computer to perform any of the methods described above. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A flowchart illustrating a document generation method provided in an embodiment of this application; Figure 2 This application provides a schematic diagram of a pre-executed operation process as an embodiment of the present application. Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a document generation device provided in an embodiment of this application; Figure 5 This is a schematic diagram of another document generation device provided in an embodiment of this application. Detailed Implementation
[0022] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0023] This application provides a document generation method, apparatus, device, and medium to automatically generate corresponding structured and standardized target documents from input text (such as operational documents), thereby improving the efficiency of target document generation, particularly the efficiency of formulating operational rule paradigms and constructing execution plans.
[0024] The methods, apparatus, equipment, and media are based on the same concept of the application. Since the methods, apparatus, equipment, and media solve problems in similar principles, the implementation of the apparatus, equipment, media, and methods can refer to each other, and repeated parts will not be described again.
[0025] The terms "first," "second," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0026] The following examples and embodiments are to be understood as illustrative only. While this specification may refer to "a," "an," or "some" examples or embodiments in several places, this does not mean that every such reference relates to the same example or embodiment, nor does it mean that the feature applies only to a single example or embodiment. Individual features of different embodiments may also be combined to provide other embodiments. Furthermore, terms such as "comprising" and "including" should be understood not to limit the described embodiments to consisting only of those features mentioned; such examples and embodiments may also include features, structures, units, modules, etc., not specifically mentioned.
[0027] The various embodiments of this application will now be described in detail with reference to the accompanying drawings. It should be noted that the order in which the embodiments are presented in this application represents only a chronological order and does not represent the superiority or inferiority of the technical solutions provided by the embodiments.
[0028] The operational rules paradigm needs to take into account the triple requirements of external supervision, internal systems and system capabilities. The document preparation is not only highly professional, but also highly dependent on business knowledge in specific fields and understanding of context.
[0029] As enterprises increasingly consolidate and digitize their processes, rule enforcement tasks, previously scattered across various business lines, are gradually being centralized within the middleware operations team. This centralized shift faces significant challenges, primarily in the following aspects: 1) Difficulty in solidifying paradigms and high generation costs: Centralized operations require unified and standardized rule templates and execution specifications. However, due to the diversity of business operations and differences in process adaptation, each rule often needs to be re-examined, unified, and localized. Traditional methods mainly rely on "returning to historical documents + experts reviewing each rule one by one," which is inefficient, has poor reusability, and makes it difficult to guarantee business interpretability. 2) High reliance on human resources and high professional threshold: During the migration and implementation of rules, a large amount of tacit knowledge cannot be explicitly expressed through templates and must rely on experts to interpret and rewrite it according to the business context. This "human interpretation" approach lacks both systematicity and is difficult to scale for migration and application.
[0030] With the development of technologies such as natural language processing and pre-trained language models (e.g., BERT, large language models), combined with methods such as cluster analysis and text extraction, it is now possible to achieve automated professional document generation. Current research mainly focuses on the following scenarios: 1) Train AI large language or GPT models based on large data samples to automatically generate solution documents; 2) Based on manually configured templates, AI models are used to supplement and automatically generate documents.
[0031] The above methods have inherent limitations in private, closed-loop scenarios, mainly in the following aspects: First, there is a lack of training samples: internal operational data of enterprises is usually not publicly available and lacks scale, which cannot meet the training needs of large models; Second, there is a high risk of semantic misinterpretation: the generalization mechanism of large models is difficult to understand industry-specific semantics, which may result in the output of logical errors or content with compliance risks. Third, the structure is unstable and the output is difficult to control: the lack of clear templates and structural constraint mechanisms makes it difficult for the output to be used for standardized implementation.
[0032] With the continuous integration and development of natural language processing and structural induction technologies, document structure extraction and intelligent generation methods combining semantic clustering and slot awareness mechanisms have been widely applied in fields such as question-answering assistants, report generation, and news summarization. Compared with traditional methods that rely on manually defined templates, rule matching, or static dictionary recommendations for slot values, this solution, which automatically extracts general structures using semantic analysis and the longest common subsequence algorithm, and then automatically generates candidate values through an attention mechanism, offers high accuracy, business interpretability, and structural controllability. It is suitable for applications such as various operational rule paradigms, execution solutions, and ledger generation in closed scenarios.
[0033] Therefore, this application proposes an automatic generation method for operational rule paradigms and execution solutions in closed environments. This method, centered on semantic clustering and structural induction, combined with a slot-aware mechanism, enables the structured expression and automatic generation of operational knowledge in scenarios with small sample sizes, high compliance requirements, and strong business interpretability demands. Unlike the "black box" approach of large models, this application achieves controllable, structurally stable, and semantically accurate knowledge generation capabilities through traceable template extraction and context-based slot filling mechanisms, adapting to the complex, sensitive, and highly constrained operational management systems within enterprises.
[0034] In other words, the embodiments of this application propose a solution to the problem of automatically generating structured and standardized operational documents. It can be widely applied to various business systems and platforms that have requirements for outputting processes, systems, and standards, and has significant versatility and promotional value.
[0035] See Figure 1 This application provides a document generation method, including: S101. Obtain the input text of the target document to be generated, and determine the semantic vector of the input text; The document generation method provided in this application embodiment can be applied to automatically output operational guidelines, work specifications, evaluation standard documents, parameter operation plans, etc. in the intensive operation process. Therefore, the target document is the operational guidelines, work specifications, evaluation standard documents, parameter operation plans, etc., and the corresponding input text is the text of these intensive operation requirements.
[0036] In some implementations, determining the semantic vector of the input text includes: The input text is fed into the BERT model, and the BERT model outputs the semantic vector of the input text.
[0037] S102. Based on the semantic vector of the input text, perform semantic scene classification to determine the semantic cluster corresponding to the input text; In some implementations, semantically similar scenarios can be identified and formed into semantic clusters based on the semantic vectors of the input text using clustering algorithms such as HDBSCAN. Each cluster represents a typical operational business scenario.
[0038] S103. Based on the semantic cluster corresponding to the input text, find the correspondence between the pre-set semantic cluster and the template used to generate the target document, and determine the template corresponding to the input text, wherein the template corresponding to the input text includes at least one slot with an undetermined value. In other words, this embodiment of the application can determine the semantic cluster corresponding to the input sample based on the semantic cluster generated from the semantic vectors of historical samples, and establish a correspondence between the semantic cluster corresponding to the input sample and the template used to generate the target document. Therefore, in practical applications, a template can be automatically matched based on the actual input text, and the target document can be generated based on the matched template.
[0039] S104. For each slot: calculate the correlation between the slot and each token in the input text, and based on the correlation, determine the optimal slot value from the pre-set slot dictionary, and fill the slot with the optimal slot value as the value of the slot. In other words, this application embodiment can automatically generate documents through a slot-aware attention mechanism. Specifically, after a new operational requirement is input, the text is processed according to the aforementioned word segmentation and clustering steps. The text is segmented using the BERT model to obtain token vectors containing contextual information. Then, the cluster to which the token belongs is determined, and the corresponding template is locked. Finally, for each slot, the optimal word segmentation for that slot can be found by calculating the attention weight of the slot to the word.
[0040] S105. Based on the template corresponding to the input text and the value of each slot in the template corresponding to the input text, generate the target document corresponding to the input text.
[0041] In simple terms, in practical applications, when a new requirement text is input, it is first vectorized, then matched with a category, then the solution document cluster corresponding to this requirement category is found, then the common framework (i.e., template) generated by this document cluster is found, then the attention weight is calculated for each slot in the framework, and values are selected from the data dictionary to fill in the slot. After filling in the values of the slots, the target document to be generated is obtained.
[0042] The method provided in this application can be productized or output to industry clients such as banks, payment institutions, financial service providers, telecommunications, and energy companies through API capabilities to support their needs for operational system standardization, document archiving, and automatic generation of regulatory compliance documents; it also has adaptability value for external clients with functions such as customer service centers, process delivery centers, and centralized operation centers.
[0043] In some implementations, the correspondence between semantic clusters and templates used to generate target documents is pre-defined in the following manner: For the text within the semantic cluster corresponding to the input sample, the text structure and inter-word relationships are identified through syntactic dependency analysis and semantic role labeling to obtain a semantic tree; A preset algorithm is used to extract the template skeleton from the semantic tree, and variable fields are labeled as slots to obtain the template corresponding to the semantic cluster for generating the target document.
[0044] In some implementations, the preset algorithm is the Longest Common Subsequence (LCS) algorithm.
[0045] The following is an example illustrating the preprocessing steps of an embodiment of this application, including pre-setting the correspondence between semantic clusters and templates used to generate target documents, as well as the construction and maintenance of slot dictionaries.
[0046] See Figure 2 The preprocessing flow of this application embodiment includes: S201. Unified Vectorized Modeling of Input Requirements: Structured table fields (such as demand element tables) and unstructured text (such as operational descriptions of sporadic demands) are uniformly vectorized. Table fields are encoded based on a pre-defined data dictionary. Operational tags are obtained through manual form filling. Then, semantic vectors are generated from the demand text using the BERT model to form a complete "demand vector" input (i.e., vector v in Formula 5 below).
[0047] In some implementations, regarding text vectorization processing based on the BERT model: The BERT model has significant advantages in understanding context, reducing ambiguity, and improving generalization ability. It segments the input text into tokens, encodes them into vectors, and then uses a multi-layer bidirectional Transformer to model the context, ultimately outputting a contextual semantic vector for each token. For example, let Given a text sequence, a word segmenter breaks it down into a sequence of subwords. : Formula 1 In each subword After adding special characters before and after, then add each sub-word Mapping to word vectors Word vectors It contains three types of embedded information: Formula 2 in, Indicate the meaning of each character / word, Indicates the position of a word in a sentence. Indicate which sentence or paragraph the word belongs to.
[0048] Then, the word sequence of the entire input text It can be represented as: Formula 3 The E is passed through multiple Transformer encoding layers to progressively model the contextual semantics, ultimately yielding a semantic vector representation: Formula 4 In some embodiments, for semantic vectors By using a weighted average, a total vector of "requirement-document pairs" is synthesized. This is used for subsequent clustering: Formula 5 The requirement-document pair refers to the correspondence established between requirement text (referred to as requirement) and solution document (referred to as document). The requirement is the input text to be generated as the target document; the solution document is the target document.
[0049] The requirements and documents are vectorized (tokenized) separately, and then a computer-readable numerical matrix is formed, as shown in Formula 5. That is, the vector of the matrix, but the requirements and documents must maintain a corresponding relationship, that is, a requirement-document pair.
[0050] Regarding the overall vector v, after vectorizing the requirements or documents, because the lengths are different, assuming requirement 1 has 100 words and requirement 2 has 200 words, the vector matrix of requirement 1 is [100, 768] and the vector matrix of requirement 2 is [200, 768]. These two requirements are not easy to cluster, so the lengths need to be unified, that is, both become [1, 768]. Therefore, a simple weighted average is performed, that is, formula five above is used to complete the preparation before clustering.
[0051] S202, Cluster Analysis and Business Scenario Normalization: Based on the vectorized requirement text, semantically similar scenarios are identified using clustering algorithms such as HDBSCAN, forming semantic clusters (for example, clusters obtained through semantic analysis using Formula 9 below). Each cluster represents a typical operational business scenario, providing a grouping basis for subsequent template extraction.
[0052] In some implementations, regarding clustering methods optimized based on the HDBSCAN algorithm, for example: Based on the semantic vectors generated above, PCA is used for dimensionality reduction to calculate the core distance and reachability distance between vectors, and a hierarchical clustering structure is constructed. The final clusters are retained through stability scoring, as follows: The Euclidean distance between vectors is calculated using the following formula: Formula Six Where i=1…n represents all dimensions in vectors p and q.
[0053] The core distance is calculated using Formula 7 below, which is the vector calculation. : Formula 7 in, It is an eigenvector The k-nearest neighbor vector. This k is set automatically by the algorithm and requires no manual intervention.
[0054] Finally, density-accessible distance and stability scores are calculated to improve the accuracy and robustness of clustering results: After calculating the core Then, the density reachable distance between any two semantic vectors is calculated using the following formula: Formula 8 This density reachability distance takes into account both vectors. The distance is considered, as well as density, to prevent sparse regions from clustering together and to preserve the stability of high-density regions. Using reachability distance instead of the Euclidean distance in ordinary clustering algorithms has several advantages: if two points are very close, and point A is in a high-density region (small core distance) while point B is in a sparse region (large core distance), then these two points are less likely to be grouped into the same category. This logic is the core of the HDBSCAN algorithm, which considers density factors in addition to distance.
[0055] The algorithm constructs a minimum spanning tree and hierarchical clustering, performing clustering from bottom to top (labeling), and finally uses a clustering stability score (i.e., the following). To measure and maximize stability, the final clusters to be retained are determined: Formula Nine Representative density (i.e., the density obtained from formula eight above) The reciprocal of ), the larger the value, the sparser the data. , Representing vectors The density range within which a cluster exists (i.e., from the time the cluster is created until it splits) value), This indicates the stability of the cluster; generally, the higher the value, the better.
[0056] In other words, the measure of maximizing stability is because the model ultimately outputs clustering results, i.e., clusters. This algorithm uses the reciprocal of the reachability distance as a stability metric, ranging from minimum to maximum. The process of finding the minimum spanning tree can be understood as follows: if the reciprocal of the reachable distance between two points is less than the current threshold, they will be split into two clusters. The algorithm will calculate the minimum spanning tree of all points in one cluster. Then get a The range of values is used to record the changes in the cluster, and finally the sum of the values from the generation of this cluster to its split is obtained.
[0057] S203, Template Structure Extraction: For each cluster, the historical operational rule paradigm and execution solution are used to perform syntactic dependency analysis and semantic role labeling to identify text structure and word relationships (e.g., semantic tree in Formula 11 below). The template skeleton is extracted using the longest common subsequence algorithm, and variable fields are labeled as "slots." For example, pairwise dynamic programming is performed on all text within the cluster to finally extract the template. Each text differs from the template and is recorded as a slot. Finally, for each slot field, all the values that have appeared are summarized and clustered to form candidate word groups for subsequent use.
[0058] Historical operating rule paradigm is a business term. Historical operating rule paradigm and execution solution are the documents in the requirement-document pair described in this application embodiment. There are many kinds of documents in this application embodiment. For example, rule paradigm can be understood as review criteria, and execution solution can be understood as parameter operation manual.
[0059] In some implementations, LCS template extraction based on syntactic dependency parsing and semantic role labeling includes: The final retained clusters generated as described above Syntactic dependency analysis and semantic role labeling are performed on all text within the cluster.
[0060] Syntactic dependency analysis, in essence, identifies which word each word depends on (similar to the parent node of a tree) based on the part of speech of the words in a sentence, and what the type of dependency is. Generally, verbs are identified first. For example, in "I eat," "eat" is the verb (predicate), and then "I" and "eat" form a subject-predicate relationship.
[0061] Semantic role labeling, centered on the predicate in a sentence, analyzes the semantic roles played by other components within the sentence. Typically, the model labels each other component, such as event, location, purpose, etc.
[0062] For example: Construct a dependency tree to identify semantic roles and dependency relationships between words.
[0063] The dependency tree, mentioned here, is one of the methods in natural language processing used to process and identify semantic roles and dependency relationships. It's essentially labeling all word segments within a sentence / document. This step is a prerequisite for subsequent LCS (Local Sequence Chart), which uses these labels to identify common templates. Therefore, this dependency tree first identifies the semantic roles of words based on their dependency relationships, and then uses SRL (Semantic Role Labeling) to determine their semantic roles within the sentence, resulting in a labeling framework. These labels are then used for subsequent template extraction.
[0064] Specifically: set up Given a text vector that has undergone word segmentation, construct a set of dependency triples (i.e., a dependency tree) using the following formula: Formula 10 in, It is the word being modified or the head word. For the current word or modifier, It serves a semantic role, such as (as) an adjective, preposition, etc. according to The process involves identifying predicates (i.e., verbs) by traversing the dependency relationships between words, constructing a tree, identifying the root node, and thus identifying the predicate verb, thereby obtaining the semantic structure of the entire text (also known as a semantic tree), as shown in Formula 11 below: Formula Eleven in, (i.e., the above) ) is a predicate. For text fragments, corresponding The interdependence, This represents the total number of semantic roles.
[0065] Finally, the results are aggregated using the following formula (12) to generate a semantically consistent, order-independent structural representation for slot extraction: Formula 12 Introducing matching functions , to align the two structure items.
[0066] For example, if there is only one sentence: "Operations and maintenance personnel check the server status every Monday at 10:00 AM", then after processing with formulas eleven and twelve, the sentence will become: p=[(ARG0, Operations personnel), (ARGM-TMP, Every Monday at 10:00 AM), (Pred, Check), (ARG1, Server status)]; This is the semantic role-fragment relationship. When extracting common structures, we need to see if the semantic roles in each sentence are similar. The model has a built-in matching function to determine whether semantic roles are similar. This function can be understood as an algorithm. The logic is: compare each semantic role-fragment pairwise. First, check if the roles are consistent (this can be compared because the label framework is unified). Then, calculate the cosine similarity, which is to see if the angle between the vectors of the two fragments is consistent. When it is greater than a preset threshold (e.g., 0.7), then we can determine that the two fragments are consistent and are "common fragments".
[0067] For example, through the matching function Use the following formula thirteen to align the two structural items: Formula Thirteen Perform pairwise dynamic programming on all text within the cluster, and finally extract the template. Each text differs from the template and is recorded as a slot. Finally, for each slot field, all the values that have appeared are summarized and clustered to form candidate word groups for subsequent use.
[0068] In other words, following the logic above, the model iterates through all segments of all sentences within a cluster, identifies commonalities using a matching function (these are the slots), and removes non-commonalities. Since the commonalities consist of many words (representing the differences between documents), further clustering or word frequency-based data dictionaries can be generated to serve as the basis for subsequent value recommendations. Subsequent slot awareness involves matching vectors calculated using attention weights with values in this dictionary; values with high similarity are placed in the corresponding slots.
[0069] S204. Slot dictionary construction and maintenance: The historical values of each slot field are clustered to form a set of candidate values, default values, units, and rules, thus creating a slot dictionary. In some embodiments, recommendation rules can also be established for subsequent automatic value filling.
[0070] This step involves extracting the common framework, using the differences between different sentences as slot values, and maintaining these different values as a data dictionary.
[0071] For example: Sentence 1: For product packages 0001, merchants who pass verification A can join the network; Sentence 2: For product packages 0002, merchants who pass verification B can join the network; Sentence 3: Product package 0003, merchant review passed C assessment.
[0072] The common part of these three sentences (A, B, and C are for illustrative purposes only, and the specific content can be determined according to actual needs) is the product package, verification conditions, and evaluation results. Then, 0001, 0002, and 0003 are the values of the data dictionary, and the slot values will be selected from the data dictionary after semantic perception.
[0073] In some implementations, the attention mechanism for slot awareness includes:
[0074] After new operational requirements are input, the text is processed according to the above-mentioned word segmentation and clustering steps. The text is segmented using the BERT model to obtain token vectors containing contextual information. Then, the cluster to which it belongs is determined, and the corresponding template is locked. Then, for each slot, the attention weight of the slot to the word is calculated using the following formula fourteen to find the most relevant word in the input sentence.
[0075] For each slot, a vector can be assigned based on its historical values; this vector is the embedding vector. Then, for new input, the new text is vectorized and segmented to obtain a vector representation of each token.
[0076] Finally, Formula 14 is used to iterate through the expression vector of each token for the current j-th slot, and calculate the correlation weight between the embedding vector of the j-th slot and the expression vector of each token, for example, denoted as α. This α is a probability because the logarithm of the numerator and denominator is taken.
[0077] Formula Fourteen
[0078] in, This represents the embedding vector of the j-th slot. This represents the BERT representation vector of the i-th token. This represents the learnable weight matrix. This represents the attention weight of the j-th slot to the i-th word. The value is normalized by taking the base of the natural logarithm of the upper and lower bounds. Formula fourteen calculates the attention weight of the slot. Focus on the probability of the i-th word in the sentence. In other words, Formula 14 calculates the correlation between the embedding vector of the j-th slot and the representation vector of the i-th token in the current input sentence.
[0079] Finally, by weighted averaging, for example using Formula 15, the overall representation vector of the j-th slot is obtained: Formula Fifteen Then select the value with the highest similarity between the overall representation vector and the slot dictionary; this is the optimal value to fill in for that slot.
[0080] In other words, based on the attention weight α calculated earlier, it is averaged with the input sentence vector to generate a final vector c. Then, using this final vector, values are selected from the previously generated data dictionary. The value with the highest similarity to this final vector is filled into the corresponding slot.
[0081] Because this application's embodiments meet compliance and business interpretability requirements, values should be selected from the maintained data dictionary to populate the slots. Of course, the data dictionary can be maintained at any time to ensure business updates.
[0082] After the aforementioned series of pre-executed model training steps (including vectorization, clustering, template extraction, and data dictionary formation), in practical applications, for new input text, the model determines its cluster and matches it with existing templates. Then, using a slot context-aware mechanism, for each slot, the relevance between that slot and each token in the input text is calculated, the optimal slot value is recommended and filled into that slot, generating the target document (structured document) corresponding to the input text, and outputting the target document.
[0083] In some implementations, the semantic vector of the input text is output through the BERT model, including: Determine the text sequence of the input text (e.g.) ); The text sequence is broken down into a sequence of sub-words using a word segmenter (as shown in Formula 1 above, for example). Each of the sub-words is mapped to a word vector (as shown in Formula 2 above), resulting in a set of word vectors corresponding to the text sequence of the input text (as shown in Formula 3 above). The word vector set is passed through multiple Transformer encoding layers to perform contextual semantic modeling, and finally the semantic vector of the input text is obtained (as shown in Formula 4 above).
[0084] In some embodiments, the method further includes: For the semantic vector of the input text, a weighted average is used to finally determine the overall vector of the input text (as shown in Formula 5 above).
[0085] In some implementations, semantic scene classification is performed based on the semantic vector of the input text to determine the semantic cluster corresponding to the input text, including: Based on the semantic vectors of the input text, the core distance between semantic vectors is calculated after dimensionality reduction using principal component analysis (PCA) (as shown in Formula 7 above). Based on the core distance between the semantic vectors, the density reachable distance between the semantic vectors is calculated (for example, as shown in Formula 8 above). Based on the density reachability distance between the semantic vectors, the semantic cluster corresponding to the input text is determined by the clustering stability score (as shown in Formula 9 above).
[0086] In some implementations, for each slot: calculating the relevance of the slot to each token in the input text, and determining the optimal slot value from a pre-set slot dictionary based on the relevance, including: For each of the aforementioned slots: Based on the historical values of the slot, determine the embedding vector corresponding to the slot; and determine the expression vector of each token in the input text. Calculate the relevance weight between the embedding vector of the slot and the expression vector of each token in the input text (for example, as shown in Formula XIV above). For the aforementioned relevance weights, the overall expression vector of the slot is determined by weighted averaging (for example, as shown in Formula 15 above). From the pre-set slot dictionary, select the value with the highest similarity to the overall representation vector of the slot, and determine it as the best slot value to be filled in the slot.
[0087] In some embodiments, the method further includes: Update the template, and / or update the slot dictionary.
[0088] In other words, this application's embodiments support a closed-loop system of manual verification and feedback: it allows manual editing and correction of the generated template structure or field values. The system automatically identifies structural changes and updates the slot dictionary and recommendation rules to achieve evolutionary optimization.
[0089] In summary, this application proposes an automatic generation technology for rule paradigms and execution solutions in closed-loop private domains. It primarily utilizes techniques such as semantic clustering, structural induction, and slot context-aware recommendation to automatically summarize standardized templates for rule paradigms and execution solutions in closed-loop scenarios and generate personalized content. The technical solution provided by this application can achieve the following beneficial effects: 1. Demand Vector Unified Modeling Method: Transform structured table fields and unstructured sporadic text into semantic vectors to improve the ability to integrate multi-source information; 2. Semantic clustering and LCS template extraction technology: By using the clustering + longest common subsequence method, document template structure and variable slot fields can be automatically extracted, supporting structure induction and iterative evolution; 3. Slot-aware context-based value filling mechanism: Introducing an attention mechanism to perceive contextual semantics, thereby intelligently recommending values for slot fields; 4. Traceable and editable generation mechanism: The output results are generated based on the combination of templates and filled values, which has structural controllability and business interpretability.
[0090] The following describes the device or apparatus provided in the embodiments of this application, and the explanations or examples of the same or corresponding technical features as those described in the above methods will not be repeated hereafter.
[0091] An electronic device is provided in an embodiment of this application, see [link to example]. Figure 3 For example, including: Processor 600 is used to read the program from memory 620 and execute the following procedures: Obtain the input text of the target document to be generated, and determine the semantic vector of the input text; Based on the semantic vector of the input text, semantic scene classification is performed to determine the semantic cluster corresponding to the input text; Based on the semantic cluster corresponding to the input text, the correspondence between the pre-set semantic cluster and the template used to generate the target document is found, and the template corresponding to the input text is determined, wherein the template corresponding to the input text includes at least one slot with an undetermined value; For each slot: calculate the correlation between the slot and each token in the input text, and based on the correlation, determine the optimal slot value from a pre-set slot dictionary, and fill the slot with the optimal slot value as the value of the slot; Based on the template corresponding to the input text and the value of each slot in the template corresponding to the input text, the target document corresponding to the input text is generated.
[0092] In some implementations, determining the semantic vector of the input text includes: The input text is fed into the BERT model, and the BERT model outputs the semantic vector of the input text.
[0093] In some implementations, the semantic vector of the input text is output through the BERT model, including: Determine the text sequence of the input text; The text sequence is decomposed into a sub-word sequence using a word segmenter; Each of the sub-words is mapped to a word vector to obtain the set of word vectors corresponding to the text sequence of the input text; The word vector set is passed through multiple Transformer encoding layers to perform contextual semantic modeling, and finally the semantic vector of the input text is obtained.
[0094] In some embodiments, the processor 600 is further configured to read a program from the memory 620 and execute the following processes: The semantic vector of the input text is weighted and averaged to determine the overall vector of the input text.
[0095] In some implementations, semantic scene classification is performed based on the semantic vector of the input text to determine the semantic cluster corresponding to the input text, including: Based on the semantic vectors of the input text, the core distance between semantic vectors is calculated after dimensionality reduction using PCA. Based on the core distance between the semantic vectors, the density reachable distance between the semantic vectors is calculated. Based on the density reachability distance between the semantic vectors, the semantic cluster corresponding to the input text is determined by cluster stability scoring.
[0096] In some implementations, the correspondence between semantic clusters and templates used to generate target documents is pre-defined in the following manner: For the text within the semantic cluster corresponding to the input sample, the text structure and inter-word relationships are identified through syntactic dependency analysis and semantic role labeling to obtain a semantic tree; A preset algorithm is used to extract the template skeleton from the semantic tree, and variable fields are labeled as slots to obtain the template corresponding to the semantic cluster for generating the target document.
[0097] In some implementations, the preset algorithm is the Longest Common Subsequence (LCS) algorithm.
[0098] In some implementations, for each slot: calculating the relevance of the slot to each token in the input text, and determining the optimal slot value from a pre-set slot dictionary based on the relevance, including: For each of the aforementioned slots: Based on the historical values of the slot, determine the embedding vector corresponding to the slot; and determine the expression vector of each token in the input text. Calculate the relevance weight between the embedding vector of the slot and the expression vector of each token in the input text; Based on the aforementioned relevance weights, the overall expression vector of the slot is determined by weighted averaging. From the pre-set slot dictionary, select the value with the highest similarity to the overall representation vector of the slot, and determine it as the best slot value to be filled in the slot.
[0099] In some embodiments, the processor 600 is further configured to read a program from the memory 620 and execute the following processes: Update the template, and / or update the slot dictionary.
[0100] Transceiver 610 is used to receive and send data under the control of processor 600.
[0101] Among them, Figure 3 In this context, the bus architecture can include any number of interconnected buses and bridges, specifically linking various circuits of one or more processors represented by processor 600 and memory represented by memory 620 together. The bus architecture can also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides an interface. The transceiver 610 can be multiple components, including transmitters and receivers, providing a unit for communicating with various other devices over a transmission medium, including wireless channels, wired channels, optical fibers, etc. For different user equipment, the user interface 630 can also be an interface capable of connecting external or internal devices, including but not limited to keypads, displays, speakers, microphones, joysticks, etc.
[0102] The processor 600 is responsible for managing the bus architecture and general processing, while the memory 620 can store the data used by the processor 600 when performing operations.
[0103] In some implementations, the processor 600 may be a CPU (Central Processing Unit), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array), or a CPLD (Complex Programmable Logic Device), and the processor may also employ a multi-core architecture.
[0104] The processor executes any of the methods described in the embodiments of this application according to the obtained executable instructions by calling a computer program stored in memory. The processor and memory may also be physically separated.
[0105] It should be noted that the apparatus provided in this application embodiment can implement all the method steps implemented in the above method embodiment and can achieve the same technical effect. Here, the parts that are the same as those in the method embodiment and the beneficial effects will not be described in detail.
[0106] See Figure 4 This application provides a document generation apparatus, comprising: Semantic vector unit 11 is used to acquire the input text of the target document to be generated and to determine the semantic vector of the input text; The classification unit 12 is used to perform semantic scene classification based on the semantic vector of the input text and determine the semantic cluster corresponding to the input text; The template determination unit 13 is used to find the correspondence between the pre-set semantic cluster and the template used to generate the target document based on the semantic cluster corresponding to the input text, and determine the template corresponding to the input text, wherein the template corresponding to the input text includes at least one slot with an undetermined value; The slot value determination unit 14 is used for each slot to: calculate the correlation between the slot and each token in the input text, and based on the correlation, determine the optimal slot value from a pre-set slot dictionary, and fill the slot with the optimal slot value as the value of the slot. The generation unit 15 is used to generate a target document corresponding to the input text based on the template corresponding to the input text and the value of each slot in the template corresponding to the input text.
[0107] In some implementations, the semantic vector unit 11 determines the semantic vector of the input text, including: The input text is fed into the BERT model, and the BERT model outputs the semantic vector of the input text.
[0108] In some implementations, the semantic vector unit 11 outputs the semantic vector of the input text through the BERT model, including: Determine the text sequence of the input text; The text sequence is decomposed into a sub-word sequence using a word segmenter; Each of the sub-words is mapped to a word vector to obtain the set of word vectors corresponding to the text sequence of the input text; The word vector set is passed through multiple Transformer encoding layers to perform contextual semantic modeling, and finally the semantic vector of the input text is obtained.
[0109] In some embodiments, the semantic vector unit 11 is further used for: The semantic vector of the input text is weighted and averaged to determine the overall vector of the input text.
[0110] In some implementations, the classification unit 12 performs semantic scene classification based on the semantic vector of the input text to determine the semantic cluster corresponding to the input text, including: Based on the semantic vectors of the input text, the core distance between semantic vectors is calculated after dimensionality reduction using PCA. Based on the core distance between the semantic vectors, the density reachable distance between the semantic vectors is calculated. Based on the density reachability distance between the semantic vectors, the semantic cluster corresponding to the input text is determined by cluster stability scoring.
[0111] In some implementations, the template determination unit 13 is further configured to pre-set the correspondence between semantic clusters and templates used to generate target documents in the following manner: For the text within the semantic cluster corresponding to the input sample, the text structure and inter-word relationships are identified through syntactic dependency analysis and semantic role labeling to obtain a semantic tree; A preset algorithm is used to extract the template skeleton from the semantic tree, and variable fields are labeled as slots to obtain the template corresponding to the semantic cluster for generating the target document.
[0112] In some implementations, the preset algorithm is the Longest Common Subsequence (LCS) algorithm.
[0113] In some implementations, the slot value determination unit 14, for each slot, calculates the relevance of the slot to each token in the input text, and determines the optimal slot value from a pre-set slot dictionary based on the relevance, including: For each of the aforementioned slots: Based on the historical values of the slot, determine the embedding vector corresponding to the slot; and determine the expression vector of each token in the input text. Calculate the relevance weight between the embedding vector of the slot and the expression vector of each token in the input text; Based on the aforementioned relevance weights, the overall expression vector of the slot is determined by weighted averaging. From the pre-set slot dictionary, select the value with the highest similarity to the overall representation vector of the slot, and determine it as the best slot value to be filled in the slot.
[0114] In some implementations, see Figure 5 The device further includes: Update unit 16 is used to update the template and / or update the slot dictionary.
[0115] It should be noted that the division of units in the embodiments of this application is illustrative and only represents one logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units described above can be implemented in hardware or as software functional units.
[0116] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0117] Any of the devices or apparatuses provided in the embodiments of this application can specifically be desktop computers, portable computers, smartphones, tablet computers, personal digital assistants (PDAs), etc. They may include a central processing unit (CPU), memory, input / output devices, etc. Input devices may include keyboards, mice, touchscreens, etc., and output devices may include display devices such as liquid crystal displays (LCDs) and cathode ray tubes (CRTs).
[0118] The memory may include read-only memory (ROM) and random access memory (RAM), and provides the processor with program instructions and data stored in the memory. In the embodiments of this application, the memory may be used to store the program of any of the methods provided in the embodiments of this application.
[0119] The processor executes any of the methods described in the embodiments of this application according to the program instructions stored in the memory.
[0120] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the methods described in the above embodiments. The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0121] This application provides a computer-readable storage medium for storing computer program instructions used in the apparatus provided in the above-described embodiments, including a program for performing any of the methods provided in the above-described embodiments. The computer-readable storage medium may be a non-transitory computer-readable medium.
[0122] The computer-readable storage medium can be any available medium or data storage device that a computer can access, including but not limited to magnetic storage (e.g., floppy disks, hard disks, magnetic tapes, magneto-optical disks (MOs), etc.), optical storage (e.g., CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (e.g., ROMs, EPROMs, EEPROMs, non-volatile memory (NAND flash), solid-state drives (SSDs)).
[0123] It should be understood that: The access technology used by entities in a communication network to transmit traffic can be any suitable current or future technology, such as WLAN (Wireless Local Access Network), WiMAX (WiMAX), LTE, etc. A. 5G, Bluetooth, infrared, etc.; in addition, the embodiments may also apply wired technologies, such as IP-based access technologies, such as wired networks or fixed lines.
[0124] An embodiment suitable for implementation as software code or as part thereof and for operation using a processor or processing capabilities is independent of the software code and can be specified using any known or future-developed programming language, such as high-level programming languages, such as Objective-C. C, C++, C#, Java, Python, Javascript, other scripting languages, or low-level programming languages such as machine language or assemblers.
[0125] The implementation of the embodiments is hardware-independent and can be implemented using any known or future-developed hardware technology or any combination thereof, such as microprocessors or CPUs (Central Processing Units), MOS (Metal-Oxide-Semiconductor), CMOS (Complementary MOS), BiMOS (Bipolar MOS), BiCMOS (Bipolar CMOS), ECL (Emitter-Coupled Logic), and / or TTL (Transistor-Transistor-Transistor). Transistor logic).
[0126] The embodiments may be implemented as individual devices, apparatuses, units, components or functions, or in a distributed manner. For example, one or more processors or processing functions may be used or shared in the process, or one or more processing segments or processing portions may be used and shared in the process, wherein one or more physical processors may be used to implement one or more processing portions dedicated to a particular process as described.
[0127] The device can be implemented by a semiconductor chip, a chipset, or a (hardware) module that includes such a chip or chipset.
[0128] The implementation can also be implemented as any combination of hardware and software, such as ASIC (Application-Specific IC (Integrated Circuit)) components, FPGA (Field Programmable Gate Array) or CPLD (Complex Programmable Logic Device) components or DSP (Digital Signal Processor) components.
[0129] The embodiments can also be implemented as computer program products, including a computer-usable medium in which computer-readable program code is embodied, the computer-usable program code being adapted to perform the processes described in the embodiments, wherein the computer-usable medium may be a non-transitory medium.
[0130] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0131] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0132] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0133] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0134] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A document generation method, characterized in that, The method includes: Obtain the input text of the target document to be generated, and determine the semantic vector of the input text; Based on the semantic vector of the input text, semantic scene classification is performed to determine the semantic cluster corresponding to the input text; Based on the semantic cluster corresponding to the input text, the correspondence between the pre-set semantic cluster and the template used to generate the target document is found, and the template corresponding to the input text is determined, wherein the template corresponding to the input text includes at least one slot with an undetermined value; For each slot: calculate the correlation between the slot and each token in the input text, and based on the correlation, determine the optimal slot value from a pre-set slot dictionary, and fill the slot with the optimal slot value as the value of the slot; Based on the template corresponding to the input text and the value of each slot in the template corresponding to the input text, the target document corresponding to the input text is generated.
2. The method according to claim 1, characterized in that, Determining the semantic vector of the input text includes: The input text is fed into the BERT model, and the BERT model outputs the semantic vector of the input text.
3. The method according to claim 2, characterized in that, The semantic vector of the input text is output by the BERT model, including: Determine the text sequence of the input text; The text sequence is decomposed into a sub-word sequence using a word segmenter; Each of the sub-words is mapped to a word vector to obtain the set of word vectors corresponding to the text sequence of the input text; The word vector set is passed through multiple Transformer encoding layers to perform contextual semantic modeling, and finally the semantic vector of the input text is obtained.
4. The method according to claim 3, characterized in that, The method further includes: The semantic vector of the input text is weighted and averaged to determine the overall vector of the input text.
5. The method according to claim 4, characterized in that, Based on the semantic vector of the input text, semantic scene classification is performed to determine the semantic cluster corresponding to the input text, including: Based on the semantic vectors of the input text, the core distance between semantic vectors is calculated after dimensionality reduction using PCA. Based on the core distance between the semantic vectors, the density reachable distance between the semantic vectors is calculated. Based on the density reachability distance between the semantic vectors, the semantic cluster corresponding to the input text is determined by cluster stability scoring.
6. The method according to claim 1, characterized in that, The mapping between semantic clusters and templates used to generate the target document is pre-defined in the following manner: For the text within the semantic cluster corresponding to the input sample, the text structure and inter-word relationships are identified through syntactic dependency analysis and semantic role labeling to obtain a semantic tree; A preset algorithm is used to extract the template skeleton from the semantic tree, and variable fields are labeled as slots to obtain the template corresponding to the semantic cluster for generating the target document.
7. The method according to claim 6, characterized in that, The preset algorithm is the Longest Common Subsequence (LCS) algorithm.
8. The method according to claim 1, characterized in that, For each slot: calculate the relevance of the slot to each token in the input text, and based on the relevance, determine the optimal slot value from a pre-set slot dictionary, including: For each of the aforementioned slots: Based on the historical values of the slot, determine the embedding vector corresponding to the slot; and determine the expression vector of each token in the input text. Calculate the relevance weight between the embedding vector of the slot and the expression vector of each token in the input text; Based on the aforementioned relevance weights, the overall expression vector of the slot is determined by weighted averaging. From the pre-set slot dictionary, select the value with the highest similarity to the overall representation vector of the slot, and determine it as the best slot value to be filled in the slot.
9. The method according to claim 1, characterized in that, The method further includes: Update the template, and / or update the slot dictionary.
10. A document generation device, characterized in that, The device includes: A semantic vector unit is used to acquire the input text of the target document to be generated and to determine the semantic vector of the input text; The classification unit is used to perform semantic scene classification based on the semantic vector of the input text and determine the semantic cluster corresponding to the input text; The template determination unit is used to find the correspondence between the pre-set semantic cluster and the template used to generate the target document based on the semantic cluster corresponding to the input text, and determine the template corresponding to the input text, wherein the template corresponding to the input text includes at least one slot with an undetermined value; The slot value determination unit is used for each slot to: calculate the correlation between the slot and each token in the input text, and based on the correlation, determine the optimal slot value from a pre-set slot dictionary, and fill the slot with the optimal slot value as the value of the slot; The generation unit is used to generate a target document corresponding to the input text based on the template corresponding to the input text and the value of each slot in the template corresponding to the input text.
11. The apparatus according to claim 10, characterized in that, The semantic vector unit determines the semantic vector of the input text in the following manner: Determine the text sequence of the input text; The text sequence is decomposed into a sub-word sequence using a word segmenter; Each of the sub-words is mapped to a word vector to obtain the set of word vectors corresponding to the text sequence of the input text; The word vector set is passed through multiple Transformer encoding layers to perform contextual semantic modeling, and finally the semantic vector of the input text is obtained.
12. The apparatus according to claim 10, characterized in that, The slot value determination unit is specifically used for: For each of the aforementioned slots: Based on the historical values of the slot, determine the embedding vector corresponding to the slot; and determine the expression vector of each token in the input text. Calculate the relevance weight between the embedding vector of the slot and the expression vector of each token in the input text; Based on the aforementioned relevance weights, the overall expression vector of the slot is determined by weighted averaging. From the pre-set slot dictionary, select the value with the highest similarity to the overall representation vector of the slot, and determine it as the best slot value to be filled in the slot.
13. The apparatus according to claim 10, characterized in that, The device further includes: An update unit is used to update the template and / or update the slot dictionary.
14. An electronic device, characterized in that, include: Memory, used to store program instructions; A processor is configured to invoke program instructions stored in the memory and execute the method according to any one of claims 1 to 9.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing the computer to perform the method according to any one of claims 1 to 9.