File generation processing method and device and storage medium
By adding semantic tags to the file generation tool and building a mapping model, the problems of missing information and insufficient accuracy caused by different data source formats are solved, and efficient and accurate matching of file generation is achieved.
Patent Information
- Application Number
- CN202511457178.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-13
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2045-10-13
AI Technical Summary
Traditional document generation tools suffer from incomplete information extraction, insufficient accuracy, and misunderstanding of context due to the varying formats of different data sources, making it impossible to match the format specifications and professional requirements of the original template.
Semantic tags are added to the first target data through semantic analysis to generate the second target data. A mapping model is built based on multiple types of data sources and semantic tags. A matching target mapping model is selected from the preset mapping models to determine the third target data that has a mapping relationship with the second target data.
It improves the accuracy and versatility of document generation, reduces blind retrieval of data sources, and ensures the accuracy and efficiency of data association.
Smart Images

Figure CN120930596A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, specifically to a file generation processing method, processing device, and storage medium. Background Technology
[0002] Traditional document generation tools typically convert reference files to Markdown format first, then use the Markdown file as context for the Large Language Model (LLM) to understand and process, and finally output the generated document via a dialog box. During the document generation process, the varying formats of reference files from different data sources can easily lead to missing information, insufficient precision in information extraction, and misunderstandings of the context, resulting in the replacement file failing to match the format specifications and professional requirements of the original template. Summary of the Invention
[0003] The purpose of this application is to provide a document generation processing method, processing device, and storage medium to solve the problem of low accuracy in traditional document generation.
[0004] To achieve the above objectives, the first aspect of this application provides a method for generating documents, comprising: Extract the first target data to be processed from the first document; Semantic tags are added to the first target data through semantic analysis to generate the second target data; Based on the semantic tags of the second target data, a target mapping model matching the second target data is selected from a plurality of preset mapping models. The mapping model is constructed based on the mapping relationship between multiple types of data sources and multiple types of semantic tags. Based on the target mapping model, a third target data that has a mapping relationship with the second target data is determined from the target data source.
[0005] A second aspect of this application provides a document generation processing apparatus, comprising: The extraction module is used to extract the first target data to be processed from the first document; The generation module is used to add semantic tags to the first target data through semantic analysis to generate the second target data; The selection module is used to select a target mapping model that matches the second target data from a plurality of preset mapping models based on the semantic tags of the second target data. The mapping model is constructed based on the mapping relationship between multiple types of data sources and multiple types of semantic tags. The determination module is used to determine, based on the target mapping model, a third target data that has a mapping relationship with the second target data from the target data source.
[0006] A third aspect of this application provides a computer-readable storage medium storing a program that can be loaded by a processor and executed using the file generation processing method described above.
[0007] The beneficial effects of this application are: This application adds semantic tags to the first target data through semantic analysis, generating second target data containing semantic tags. This adds explicit semantic attributes to the data, providing a precise data foundation for subsequent mapping and matching, and solving the matching errors caused by semantic ambiguity in traditional data extraction. This application also constructs a pre-defined mapping model based on multiple types of data sources and multiple types of semantic tags. Then, based on the semantic tags of the second target data, a target mapping model matching the second target data is selected to determine the third target data that has a mapping relationship with the second target data from the target data source. In this way, blind searching of data sources can be reduced, improving the efficiency of determining related data from data sources. Furthermore, multiple mapping models can adapt to different data source types in different scenarios, improving the versatility and accuracy of file generation.
[0008] Other features and advantages of this application will be described in detail in the following detailed description section. Attached Figure Description
[0009] Figure 1 This is a flowchart illustrating a file generation method provided in an embodiment of this application. Figure 2 This is a flowchart illustrating a file generation method provided in a specific embodiment of this application; Figure 3 This is a schematic diagram of the structure of a file generation processing device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of a file generation processing system provided in the embodiments of this application. Detailed Implementation
[0010] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0011] In the description of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified. In this application, the term "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to implement and use this application. In the following description, details are set forth for illustrative purposes. It should be understood that those skilled in the art will recognize that this application can be implemented without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid unnecessary detail that would obscure the description of this application. Therefore, this application is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0012] Figure 1 This is a flowchart illustrating a file generation method provided in an embodiment of this application. Figure 1 As shown, this processing method may include steps 101-104, which will be described in detail below.
[0013] Step 101: Extract the first target data to be processed from the first document.
[0014] In this embodiment, the first document refers to a template document for file generation, used to standardize the format and content framework of the generated file. The first document may include a fixed structure and format, as well as content that needs to be filled or replaced, i.e., the first target data. The first target data refers to the content fragments extracted from the first document that need further processing; it is the specific object that needs to be filled or replaced. The first document is the carrier of the first target data to be processed, defining the format and scope of the generated file, while the first target data is the specific data content that needs to be processed; together, they constitute the initial input basis for file generation.
[0015] Step 102: Add semantic tags to the first target data through semantic analysis to generate the second target data.
[0016] In this embodiment, semantic tags refer to structured identifiers added to the first target data through semantic analysis to describe the attributes and processing requirements of the first target data. This transforms the ambiguous semantics of the first target data into explicit semantic information, clarifying the subsequent processing direction. The second target data is the first target data with added semantic tags. Subsequently, by parsing the semantic tags of the second target data, the efficiency of determining the requirements for the first target data can be improved. Thus, a semantically clear and well-defined data foundation is provided for subsequent data processing.
[0017] Step 103: Based on the semantic tags of the second target data, select a target mapping model that matches the second target data from multiple preset mapping models. The mapping model is constructed based on the mapping relationship between multiple types of data sources and multiple types of semantic tags.
[0018] In this embodiment, the mapping model is a set of rules used to describe the association between specific types of semantic tags and data sources. The mapping model connects the semantic requirements corresponding to semantic tags with the source files that provide the data. The mapping model can cover rules for multiple scenarios, thus solving the problem of different association logics for different types of data. As an example, the mapping model can be trained using historical data to establish association rules between different semantic tags and data sources. Taking the pharmaceutical industry as an example, semantic tags of the "process parameters" type can be associated with "production record databases" and "equipment operation manual libraries," etc.
[0019] The target mapping model is based on the semantic labels of the second target data, selecting the most matching mapping model from multiple mapping models, thereby improving the accuracy and efficiency of data association. As an example, the mapping relationship between the semantic labels contained in each mapping model and the data source can be assigned corresponding weights. By matching the applicable label range of each mapping model through semantic labels, the mapping model with the highest weight can be selected as the target mapping model.
[0020] By pre-setting multiple mapping models, different scenarios can be covered, solving the problem of insufficient adaptability of a single model and enhancing the versatility for diverse file generation needs. Selecting the target mapping model that matches the second target data based on semantic tags reduces blind searching of data sources and improves the efficiency of data source location.
[0021] Step 104: Based on the target mapping model, determine the third target data that has a mapping relationship with the second target data from the target data source.
[0022] In this embodiment, the third target data is data that is semantically related to the second target data, selected from the target data source based on the rules of the target mapping model. The target data source is the data source that matches the semantic tags of the second target data, as determined by the target mapping model. The third target data can meet the processing requirements of the second target data, such as supplementation, replacement, matching, and verification. Based on the target mapping model, the third target data related to the second target data can be accurately located based on the type of the second target data, reducing the mixing of irrelevant information, providing reliable associated data support for document generation, and improving the accuracy of data association. This allows the first document to be transformed from a template framework to a complete document containing accurate information.
[0023] This application embodiment adds semantic tags to the first target data through semantic analysis, generating second target data containing semantic tags. This adds explicit semantic attributes to the data, providing a precise data foundation for subsequent mapping and matching, and solving the matching errors caused by semantic ambiguity in traditional data extraction. This application embodiment also constructs a preset mapping model based on multiple types of data sources and multiple types of semantic tags. Then, based on the semantic tags of the second target data, a target mapping model matching the second target data is selected to determine the third target data that has a mapping relationship with the second target data from the target data source. In this way, blind searching of data sources can be reduced, improving the efficiency of determining related data from data sources. Furthermore, multiple mapping models can adapt to different data source types in different scenarios, improving the universality and accuracy of file generation.
[0024] This embodiment first requires extracting the data to be processed from the first document. However, if only the labeled data is extracted, inconsistencies in information or logical errors may occur. Therefore, the first target data to be extracted in step 101 must retain the original logic of the first document while focusing on the key content to be processed.
[0025] Based on this, in step 101, the first document can be parsed first, and the element data in the first document whose format attributes match the preset format attributes can be used as annotation data.
[0026] Parsing the first document refers to performing structured parsing on it, using document parsing tools to identify its underlying formatting information and content. Taking a Word document as an example, it can be parsed into a structured document. As an example, the OpenXML parser can identify element data, as well as the corresponding font styles, paragraph layouts, element types, placeholders, etc. Element data refers to the smallest unit of content in a document with independent formatting attributes, such as a sentence, a table cell, and a placeholder tag. Formatting attributes refer to the formatting characteristics of element data, such as font color, background color, font style, special tags, and style names.
[0027] In the first document, fixed data can be used as unchanging template information, while the data to be processed is labeled according to preset format attributes. For example, the preset format attribute can be set to a yellow background. Then, the elements with a yellow background in the first document are used as labeled data. By automatically matching format attributes instead of manual screening, the chances of missed detections or false positives can be reduced, thus improving the recognition efficiency of labeled data.
[0028] In step 101, based on the structural relationship of the preset nodes in the first document, the associated data that has a semantic relationship with the labeled data is determined.
[0029] In this embodiment, a preset node refers to a pre-defined structured unit in the first document. The structural relationship of a preset node may include hierarchical nesting or sequential relationships. In one example, a preset node may include sections and paragraphs. The structural relationship between sections or paragraphs may be sequential, for example, paragraph A precedes paragraph B. The relationship between sections and paragraphs may be hierarchical nesting, such as a paragraph belonging to a section.
[0030] Based on the structural relationships of predefined nodes, the correlations between elements in the first document can be inferred. Therefore, the structural relationships of predefined nodes can aid in understanding the contextual information of the labeled data, thereby identifying related data with semantic relationships to the labeled data. For example, if the labeled data is a paragraph of a table, the table title of the previous paragraph is usually considered as semantically related data. This solves the semantic fragmentation problem caused by traditional isolated data extraction, providing a more complete semantic environment for subsequent semantic analysis.
[0031] As an example, we can first obtain the element type and target paragraph of the labeled data. Element type refers to the content attribute classification of the element data, indicating its nature. Target paragraph refers to the specific paragraph of the labeled data within the first document, which can be determined using the paragraph index. By obtaining the attributes and location of the labeled data, we can provide a basis for subsequent extraction of related data, thereby using different extraction logic for different types of labeled data and improving the accuracy of related data extraction.
[0032] If the element type of the labeled data is the target type, then paragraph data from adjacent paragraphs that have a semantic relationship with the target paragraph are extracted as the first associated data of the labeled data. The target type refers to the element type that requires semantic support through context. The first associated data is the data used to semantically support the labeled data, supplementing the contextual information of the labeled data. Based on the semantic coherence rule, it is necessary to associate the data with the surrounding paragraphs of the target paragraph, and the paragraph data from paragraphs that have a semantic relationship with the target paragraph are used as the first associated data of the labeled data. For example, for image types, the corresponding image description needs to be extracted; for table types, the table name needs to be extracted, etc.
[0033] Then, based on the target paragraph and the target section to which it belongs, structural data for the labeled data is generated, and this structural data serves as the second set of related data within the labeled data. The target section refers to the highest-level structural unit to which the target paragraph belongs, and is a core node in the document's hierarchical system. The structural data, on the other hand, is the organizational information describing the location of the labeled data within the document, reflecting its hierarchy within the overall framework. The second set of related data, existing in the form of structural data, is used to clarify the hierarchical position of the labeled data. Clarifying the location of labeled data through structural data resolves the issue of the same term having different meanings in different document locations, providing a locational basis for subsequent data tracing.
[0034] The first and second related data are then integrated to obtain related data that has a semantic relationship with the labeled data. Integrating the first related data, which represents the contextual semantic environment of the labeled data, with the second related data, which represents the structural position of the labeled data, can form dual semantic support of content and structure. This allows the related data to both explain the context of the labeled data and clarify its position, thus providing complete data evidence.
[0035] Finally, in step 101, the labeled data and associated data are integrated to obtain the first target data. The labeled data serves as the core data to be processed, while the associated data serves as contextual auxiliary information. By merging them according to preset rules, a complete structured data unit containing the core content and associated context can be formed. This reduces information fragmentation, allowing subsequent semantic analysis to be based on a complete context and reducing misjudgments caused by incomplete input information.
[0036] As an example, we can start by using the target section as the first level, associating its section identifier, title data, and page attributes. A section represents a logical chapter or module in the document (such as "process parameters," "operation steps," and "quality control"), used to organize lower-level content. As the top-level structural unit, each section can include a unique section identifier (sectionID) and title, containing a list of subordinate paragraphs, tables, images, etc. Using the target section as the highest level can be used to define the subject scope and location of the first target data. Associating the section identifier corresponding to the target section clarifies the first-level position of the first target data; associating the title data clarifies the subject information of the target section; and associating the page attributes clarifies the physical location of the target section within the document. In this way, we can clearly define the macro-level subject affiliation, reduce confusion of similar data under different subjects, and the page attributes also facilitate tracing back to the target section's location.
[0037] Then, using the target paragraph as the second level, we associate its paragraph index, style attributes, and section identifier. A paragraph is the intermediate level connecting sections and element data. Within each section, a unique index value can be assigned to each paragraph according to its sequential position, identifying its position within the section. Each paragraph also has corresponding style attributes, such as formatting attributes, to reflect its structural characteristics. The target paragraph is the paragraph containing the first target data. By associating the target paragraph's paragraph index and its section identifier, sections and paragraphs are bound together, forming a nested structure that ensures the continuity of the data structure. Style attributes can help determine the semantic weight of the target paragraph, providing contextual clues for semantic analysis.
[0038] Next, the element data included in the target paragraph is used as the third level to record the content data, element type, and format attributes of the element data. Element data, as the lowest level unit, is used to record the micro-characteristics of the element data. Content data refers to the content information contained in the element data. Element types can include text data, image data, and tabular data, used to define the data processing requirements. For example, text data is the actual text content in the paragraph, supporting rich text attributes (such as bold, color, and highlight), and can be used as a core field of the paragraph, while also recording whether it is annotated (such as highlighted, background color), and extracting the background color (such as "highlight": "yellow"). Tabular data is a structured data container used to represent parameter configurations, bills of materials, and process steps, and can be represented as a two-dimensional array or object array, containing table headers and data rows. Image data is embedded images or charts, with accompanying descriptive information and reference paths, and can contain metadata such as imageId, src (file path or Base64 encoding), alt (alternate text), and caption (caption). Format attributes refer to the format characteristics of the element data, providing a basis for identifying and annotating the data.
[0039] Then, based on the defined hierarchical order, the data from the first, second, and third levels are integrated to obtain the first target data. For example, the data can be nested from top to bottom according to the order of the first, second, and third levels to form a tree-structured first target data. Therefore, the first target data contains macro-themes, meso-contexts, and micro-content, providing complete semantic and structured data for semantic analysis, thus improving the efficiency and accuracy of data processing.
[0040] In step 102, the content features of the first target data can be determined based on the element types. Content features are features that describe the specific attributes of elements extracted based on their element types. As an example, content features can be extracted using extraction rules corresponding to the element types. Transforming the first target data into parsable content features allows for targeted feature extraction based on element types, reducing interference from irrelevant information.
[0041] Then, combining the pre-built knowledge base, semantic tags corresponding to the content features are generated according to the rules corresponding to the element types. These semantic tags are then added to the first target data to generate the second target data.
[0042] A knowledge base can contain a collection of professional knowledge related to the current document's domain, such as a domain terminology database, rule base, and semantic association rules. Incorporating a domain-specific knowledge base can address the problem of general semantic models' insufficient understanding of specialized domains, thus improving the accuracy of semantic analysis. For different element types, a pre-defined mapping logic between content features and semantic tags can be used to find the semantic tags corresponding to the content features. Semantic tags are structured identifiers used to describe the semantic attributes of the primary target data.
[0043] As an example, semantic tags for sections can be generated by matching topic keywords with a domain thesaurus to produce domain attribute tags. Semantic tags for paragraphs can be generated by generating intent tags based on function words and feature words. Semantic tags for text data can be generated by generating entity tags, indicator tags, and processing requirement tags based on core information. Semantic tags for tabular data can be generated by generating type tag association tags based on type and data features. Semantic tags for image data can be generated by generating topic tags and citation tags based on topic and reference information.
[0044] Semantic annotation based on preset rules and knowledge base can reduce semantic bias and improve the accuracy of semantic labels. It not only solves the problem of semantic ambiguity in data, but also provides a high-quality data foundation that is understandable, associative, and verifiable for mapping model matching.
[0045] In step 103, deeper semantic features of the second target data can be further mined based on semantic tags. Specifically, semantic analysis is performed on the second target data based on semantic tags to obtain semantic analysis results. These results can include structured indicators, intent tags, and relationship descriptions. Structured indicators are metrics that quantify or classify key attributes in the semantic tags, used to describe the structural characteristics of the second target data and determine key data indicators, definitions, and calculation methods. Intent tags can characterize the processing requirements of the second target data; for example, inferring the purpose and expected effect by analyzing paragraphs and titles. Relationship descriptions can describe the logical connections between the second target data and other entities, understanding the logic of mutual association and support between different parts of the data. Using the semantic tags of the second target data as input, key information is extracted through parsing rules and transformed into structured indicators, intent tags, and relationship descriptions. Transforming abstract semantics into concrete features facilitates subsequent requirement classification.
[0046] Then, the semantic analysis results are used as the context for the second target data and input into a pre-trained large language model to obtain the requirement classification of the second target data. Context refers to the complete semantic background provided by the semantic analysis results, used to assist the large language model in understanding the processing requirements of the second target data. Requirement classification categorizes which mapping model should be used for the second target data, serving as the basis for mapping model selection. By leveraging the large language model to understand complex semantics, the accuracy of classification can be improved.
[0047] This application embodiment allows for the pre-defined mapping relationship between demand classification and mapping models. Therefore, a target mapping model matching the second target data can be determined based on the demand classification. As an example, the target mapping model includes a tool invocation mapping model and a source file mapping model. For instance, if the demand is classified as process parameter verification, it can correspond to the source file mapping model. If the demand is classified as calculation parameter, it can correspond to the tool invocation mapping model. Directly locating the target mapping model through demand classification improves the invocation efficiency of the pre-defined model and ensures consistency with the demand, thereby ensuring the accuracy and efficiency of subsequent association with the third target data. This approach is suitable for scenarios with diverse demands and complex models.
[0048] In step 104, if the target mapping model is a tool invocation mapping model, then the first key data in the second target data is determined through semantic tags. The first key data is the core parameters extracted from the semantic tags of the second target data for invoking external tools, and serves as the input basis for tool execution. Then, the first key data, as context, is input into the large language model along with the first prompt word to determine the target tool matching the second target data, and a mapping is formed between the first path and tool parameters of the target tool and the second target data. The first prompt word is the instruction that guides the large language model to select a tool; for example, selecting a tool with computable time based on the parameter [first key data].
[0049] The target tool is an external tool recommended by the large language model that can meet the data processing needs of the second objective. The target tool can be associated with the first path and tool parameters; the first path is the calling address of the target tool, and the tool parameters are the required input parameters, etc. Through the intelligent matching tool of the large language model, it can be applied to scenarios with a large tool library and can automatically complete calculations, improving the efficiency of generating data to be processed that requires computation.
[0050] If the target mapping model is a source file mapping model, then the second key data in the second target data is determined, and a second prompt word is generated. The second key data is an identifier extracted from the second target data for matching the source file, such as filename keywords, content topics, etc. The second prompt word is an instruction that guides the large language model to locate matching content from the source file; for example, based on [second key data], a standard value is searched from the source file.
[0051] Then, the first fragment of the source file obtained through semantic slicing is used as context and input together with the second prompt word into the large language model to determine the target source file that matches the second target data. The second path and first association field of the target source file are then mapped to the second target data. To reduce the limitations of long text processing, this embodiment of the application requires first performing semantic slicing on the source file to generate fragments split according to semantic topics. The first fragment is the fragment related to the second key data in the source file after semantic slicing. The target source file is the complete file selected from the source files that matches the second target data. Inputting the first fragment as context and the second prompt word into the large language model allows for the identification of the target source file through semantic matching, returning the second path and first association field of the target source file. In this way, the target source file can be accurately located, ensuring semantic consistency between the third target data and the second target data.
[0052] In this embodiment, if no target source file corresponding to the second target data is found, the model switching logic can be triggered to activate the knowledge base mapping model and search for a third target data that matches the second target data from the knowledge base. The knowledge base mapping model serves as an alternative mapping model and is used to match data from an industry knowledge base.
[0053] Specifically, if no target source file corresponding to the second target data is matched in the source file, the target mapping model is determined to be a knowledge base mapping model, and a third prompt word is generated based on the second key data in the second target data. The third prompt word is an instruction to locate data in the knowledge base, for example, based on [second key data], to search for temperature standards in the knowledge base.
[0054] Then, the second fragment of the knowledge base file obtained through semantic slicing is used as context, and together with the third prompt word, it is input into the large language model to determine the target knowledge base file that matches the second target data. The third path and second association fields of the knowledge base file are then mapped to the second target data. Slicing the knowledge base file to generate second fragments broken down by knowledge items reduces computational load and improves matching efficiency and accuracy. By determining the target knowledge base file through structured matching and returning its third path and second association fields, the target knowledge base file can be precisely located, ensuring semantic consistency between the third and second target data.
[0055] By utilizing tool-invoking mapping models and source file mapping models, precise adaptation to different types of data sources is achieved. The tool-invoking mapping model can be used for data computation, while the source file mapping model can be used for content referencing. Furthermore, through the backup scheme mechanism of the knowledge base mapping model, the coverage and robustness of data matching are further improved, establishing multiple flexible and reliable mapping schemes for third-party data.
[0056] In data processing using large language models, due to the length limitations of the models and considering factors such as semantic understanding accuracy and processing efficiency, it is necessary to slice the reference files. The reference files are a collection of files that support data matching, which can include source files and knowledge base files. Slicing allows each segment to be stored, indexed, and retrieved separately, enabling on-demand processing without repeatedly parsing the entire reference file, thus improving matching efficiency.
[0057] Specifically, multiple reference files can be obtained and converted into a target format. The target format is a structured format that meets the conditions for semantic analysis. The target format is a structured format that can be semantically analyzed, such as Markdown, JSON, XML, or a custom key-value pair format, which can meet the machine's requirements for semantic parsing. Format conversion is the process of further converting unstructured or semi-structured reference files into a structured format to extract the semantic elements of the reference files and store them in a structured manner.
[0058] Next, semantic slicing is performed on the reference file in the target format to obtain multiple first semantic segments. These first semantic segments are the initial results of slicing the reference file. For example, slicing can be based on delimiters. However, slicing based on delimiters can easily result in semantically incomplete segments. Therefore, semantic completion is required for the first semantic segments to reduce the number of segments with missing semantics.
[0059] Based on this, multiple first semantic segments can be sequentially input into a pre-trained large language model. The model then uses contextual semantic segments to determine whether any first semantic segments are semantically incomplete. Semantic incompleteness refers to the incompleteness of information in a first semantic segment due to over-segmentation, making it difficult to express complete semantics. Contextual semantic segments assist in determining whether the current first semantic segment is semantically complete. The large language model, trained on a corpus, can identify the linguistic completeness of the current first semantic segment.
[0060] If a semantically missing first semantic segment exists, it is concatenated with the context semantic segment to obtain an extended semantic segment. This extended semantic segment is then input into the large language model for iterative semantic missing detection. The extended semantic segment is a longer segment obtained by concatenating the semantically missing first semantic segment with the context semantic segment; it is used to supplement the missing semantic information. During the completion process of the first semantic segment, there may be cases where the concatenated length is insufficient, and the extended semantic segment still lacks semantic meaning. Therefore, it is necessary to repeatedly use the large language model to detect semantic missing segments until the extended semantic segment is semantically complete.
[0061] In response to the determination that the extended semantic fragment does not contain semantic missing information, the extended semantic fragment is identified as the second semantic fragment of the reference file. The second semantic fragment is the semantically complete final fragment obtained after semantic missing information detection and expansion. The second semantic fragment can include the first fragment of the source file and the second fragment of the knowledge base file. The length of the second semantic fragment is adapted to the large language model, and it is semantically complete, providing a more accurate reference file for data matching and improving the efficiency of data matching.
[0062] Taking the conversion of a reference document to Markdown format as an example, the Markdown reference document is semantically sliced according to paragraph and heading levels to obtain the first semantic fragment, ensuring that each first fragment has a relatively independent structure and topic. Subsequently, each first semantic fragment is input into a large language model, which determines whether its content is complete based on contextual semantics.
[0063] If the model identifies semantic gaps in the current first semantic segment (such as unclear referents, missing preconditions, or logical incoherence), it automatically concatenates it with the preceding and following first semantic segments to form a text block containing complete context. This concatenated text block is then re-input into the larger model for semantic integration and completion, generating a semantically coherent and logically complete second semantic segment. This effectively reduces comprehension biases caused by isolated segments, ensuring key information is accurately parsed within its complete context, and improving the accuracy of subsequent knowledge extraction, classification, and application.
[0064] In this embodiment, after determining a third target data with a mapping relationship to the second target data from the target data source, the mapping relationship between the third target data and the first and / or second target data can be displayed on the interface. Users can verify and correct the mapping between the third target data and the first target data during file generation.
[0065] The following example uses the generation of process specifications in the pharmaceutical industry. It is assumed that a model is being built for the production process of a drug. The source documents involved include process information sheets, packaging material information, supplier directories, and job operation procedures, and a density calculation tool needs to be called. Figure 2 This is a flowchart illustrating a file generation method provided in a specific embodiment of this application. Figure 2 As shown, the method may include steps 201 to 208.
[0066] Step 201: Extract the first target data from the first document.
[0067] Assuming the first document is a Word document template with a highlighted background, containing key parameters of the process specifications (such as temperature, time, and pressure), OpenXML technology can be used to extract the content highlighted with specific background colors and convert it into a JSON string. For example, the requirement that "the reactor operating temperature must be maintained between 70-80 degrees Celsius" can be extracted.
[0068] Step 202: Add semantic tags to the first target data through semantic analysis to generate the second target data.
[0069] The extracted JSON is used as context input into a large language model for semantic analysis. This identifies and classifies different parts of the template, outputting a new JSON structure. For example, the extracted JSON is input into the large language model, which performs semantic understanding analysis. A prompt could be: "You are an intelligent document analysis assistant in the pharmaceutical manufacturing field." Based on the following structured JSON content extracted from the process specifications, please conduct in-depth semantic understanding analysis, including: A. Identifying the meaning of data indicators: Analyze key parameters in the text and tables, clarifying their definitions, units, control scope, and whether they conform to Good Manufacturing Practice (GMP) or are key parameters (such as Critical Process Parameter (CPP) or Critical Quality Attribute (CQA)); B. Understanding intent: Infer the writing purpose of each paragraph or chapter (such as guiding operation, ensuring safety, or meeting compliance); C. Logical structure analysis: Analyze the overall document structure, understand the progressive relationship of "operating conditions → safety instructions → quality control," and determine whether there are dependencies or triggering logic. Please output detailed semantic analysis results as the basis for the next classification step. The large language model outputs semantic understanding results, resulting in second target data containing semantic labels.
[0070] Step 203: Semantically slice the reference document and perform semantic completion to obtain the second semantic segment of the reference document.
[0071] After converting multiple reference documents to Markdown format, a large language model can be used for understanding and analysis. Based on the analysis results, the data slicing dimensions are determined, and the data is divided to obtain the second semantic fragment after slicing.
[0072] For example, based on semantic slicing and context completion of multi-source documents, the background description is as follows: A pharmaceutical company needs to uniformly process process documents (Word, PDF) from multiple sources for building an intelligent knowledge base in its system. The original documents include: SOP-MFG-101.docx: "Operating Procedure for Glucose Injection Preparation"; SOP-QC-205.pdf: "Intermediate Quality Inspection Standard". The goal is to convert these documents to Markdown, perform semantic slicing, and ensure the semantic integrity of each segment for subsequent use in question answering, parameter extraction, and system configuration. Step 1: Multi-source file → Markdown conversion. Use automated tools (such as pandoc + pdfplumber) to uniformly convert the documents to structured Markdown. Example output (SOP-MFG-101.md): #Operating Procedure for Glucose Injection Preparation.
[0073] The prompt for semantic completeness judgment in the large language model can be: Please judge whether the following text fragment is semantically complete. If there is unclear referent, missing premise, or logical break, please answer "missing"; otherwise, answer "complete". Text: "In this step, temperature changes must be monitored to prevent local overheating and charring." Large language model output: Missing. Reason: The referent of "this step" is unclear. The preceding text does not specify whether "this step" refers to dissolving, heating, or other operations. The specific procedure needs to be judged in conjunction with the context. Context splicing and completion recognizes that chunk_04 has semantic missingness, and automatically splices its preceding slice (chunk_03) and the following slice (if it exists) to form a complete context: ## 3.2 Temperature control: Heat to 80±5℃ and maintain for 30 minutes to promote dissolving. ## 3.3 Precautions. In this step, **temperature changes must be monitored** to prevent local overheating and charring. Re-enter the spliced content into the large language model, and the prompt is: Please restate the "precautions" part based on the complete context to make its semantics independent and clear. The output of the large language model (completed content): During the dissolution process, heating to 80±5℃ and maintaining it for 30 minutes, temperature changes must be monitored in real time to prevent local overheating that could lead to glucose caramelization. Finally, the final second semantic fragment is generated, updating the original first semantic fragment to ensure that subsequent processing uses the semantically complete version.
[0074] Step 204: Based on the semantic labels of the second target data, select a target mapping model that matches the second target data from a set of preset mapping models.
[0075] The semantic analysis results are then processed using a large language model to classify the requirements. Input prompts can be: "Classify requirements based on semantic analysis results (final output)." Based on the semantic analysis results above, please classify the annotated content into the following two categories: Tool call type: Tasks requiring the use of external tools or systems, such as formula calculations, format conversions, system interface calls, etc.; Source file association type: Content requiring the establishment of mapping relationships with external source files (such as SOPs, equipment manuals, historical batch records). Please output the structured classification results.
[0076] Step 205: If the target mapping model is a tool call mapping model, then determine the target tool that matches the second target data, and map the first path and tool parameters of the target tool to the second target data.
[0077] For parts that require calling calculation tools (such as density calculation), the corresponding JSON nodes are traversed, and the labeled content is used as context. A large language model is then used to analyze and extract the required tools and their parameters. For example, calculating the density of a batch of medicines.
[0078] Step 206: If the target mapping model is a source file mapping model, then determine the target source file that matches the second target data, and map the second path and first association field of the target source file to the second target data.
[0079] The system automatically filters out the second key data that needs to be associated with the source file based on the generated template JSON structure, and integrates this second key data into the prompt word framework. At the same time, it uses the first segment of the sliced source file as context to build a fine-grained mapping relationship network through the capabilities of a large language model.
[0080] Step 207: If no target source file corresponding to the second target data is matched in the source file, the target mapping model is determined as the knowledge base mapping model, the target knowledge base file matching the second target data is determined, and the third path and second association field of the knowledge base file are mapped to the second target data.
[0081] For parts requiring industry expertise, the relevant JSON nodes are traversed and used as query content. Related information (such as safety operating procedures for a certain material) is searched in the knowledge base, and the found content is used as context for further matching.
[0082] Step 208: Present the mapping relationship between the first target data and / or the second target data and the third target data on the display interface, and correct the mapping relationship in response to the correction operation.
[0083] Finally, the constructed relationship network is displayed on the interface for users to check and make necessary manual corrections. After ensuring that all information is accurate, the final process specification document is generated and modeled.
[0084] It's important to note that the data source files are not limited to traditional document formats such as PDF, Word, and TXT. Multimodal large language models can also be used to parse images and convert them to Markdown format, followed by coarse-grained file segmentation. Furthermore, other file types can also be included in the processing scope. In this way, regardless of the data source format, analysis and transformation can be effectively performed.
[0085] Figure 3 This is a schematic diagram of the structure of a file generation processing device 300 provided in an embodiment of this application. Figure 3As shown, the processing device 300 may include an extraction module 301, a generation module 302, a selection module 303, and a determination module 304. The extraction module 301 extracts first target data to be processed from a first document. The generation module 302 adds semantic tags to the first target data through semantic analysis to generate second target data. The selection module 303 selects a target mapping model matching the second target data from a set of preset mapping models based on the semantic tags of the second target data. The mapping model is constructed based on the mapping relationship between multiple types of data sources and multiple types of semantic tags. The determination module 304 determines third target data that has a mapping relationship with the second target data from the target data source based on the target mapping model.
[0086] In this embodiment, the extraction module 301 may include a parsing unit, an association unit, and an integration unit. The parsing unit parses the first document and uses element data whose format attributes match preset format attributes as annotation data. The association unit determines associated data that has a semantic relationship with the annotation data based on the structural relationships of preset nodes in the first document. The integration unit integrates the annotation data and associated data to obtain the first target data.
[0087] In this embodiment, the preset node may include sections and paragraphs. The association unit is further configured to obtain the element type of the annotation data and the target paragraph to which it belongs; if the element type of the annotation data is a target type, then extract the paragraph data from adjacent paragraphs that have a semantic relationship with the target paragraph as the first association data of the annotation data; based on the target paragraph and the target section to which the target paragraph belongs, generate the structure data of the annotation data, and use the structure data as the second association data in the annotation data; integrate the first association data and the second association data to obtain the association data that has a semantic relationship with the annotation data.
[0088] The integration unit is also used to associate the target section with its section identifier, title data, and page attributes as the first level; associate the target paragraph with its paragraph index, style attributes, and section identifier as the second level; and record the content data, element type, and format attributes of the element data as the third level. Based on the set hierarchical order, the data of the first, second, and third levels are integrated to obtain the first target data.
[0089] The generation module 302 may include a feature determination unit, a tag generation unit, and a tag adding unit. The feature determination unit determines the content features of the first target data based on the element types in the first target data. The tag generation unit, in conjunction with a pre-built knowledge base, generates semantic tags corresponding to the content features according to the rules corresponding to the element types. The tag adding unit adds the semantic tags to the first target data to generate the second target data.
[0090] Selection module 303 may include an analysis unit, a classification unit, and a matching unit. The analysis unit performs semantic analysis on the second target data based on semantic tags, obtaining semantic analysis results, which include structured indicators, intent tags, and relational descriptions. The classification unit uses the semantic analysis results as context for the second target data, inputting them into a pre-trained large language model to obtain a demand classification for the second target data. The matching unit determines a target mapping model that matches the second target data based on the demand classification.
[0091] In this embodiment of the application, the target mapping model includes a tool call mapping model and a source file mapping model, and the determination module 304 includes a first mapping unit, a second mapping unit and a third mapping unit.
[0092] The first mapping unit is used to determine the first key data in the second target data through semantic labels when the target mapping model is a tool calling the mapping model; the first key data is used as context and input together with the first prompt word into the large language model to determine the target tool that matches the second target data, and the first path and tool parameters of the target tool are mapped to the second target data.
[0093] The second mapping unit is used to determine the second key data in the second target data and generate the second prompt word when the target mapping model is the source file mapping model; the first fragment of the source file obtained through semantic slicing is used as the context and input together with the second prompt word into the large language model to determine the target source file that matches the second target data, and to map the second path and the first association field of the target source file with the second target data.
[0094] The third mapping unit is used to determine the target mapping model as a knowledge base mapping model when no target source file corresponding to the second target data is matched in the source file, and to generate a third prompt word based on the second key data in the second target data; the second fragment of the knowledge base file obtained through semantic slicing is used as context and input together with the third prompt word into the large language model to determine the target knowledge base file that matches the second target data, and to map the third path and the second association field of the knowledge base file with the second target data.
[0095] In this embodiment, the processing device 300 may further include an acquisition module, a slicing module, a judgment module, an extension module, and a response module. The acquisition module acquires multiple reference files and converts them into a target format. The reference files include source files and knowledge base files, and the target format is a structured format that meets semantic analysis conditions. The slicing module performs semantic slicing on the reference files in the target format to obtain multiple first semantic segments. The judgment module sequentially inputs the multiple first semantic segments into a pre-trained large language model and determines whether there are semantically missing first semantic segments based on contextual semantic segments. The extension module, in the case of semantically missing first semantic segments, concatenates the first semantic segments with contextual semantic segments to obtain extended semantic segments, and inputs the extended semantic segments into the large language model for iterative judgment of semantic missingness. The response module, in response to the determination that the extended semantic segments do not have semantic missingness, identifies the extended semantic segments as second semantic segments of the reference files. The second semantic segments include the first segments of the source files and the second segments of the knowledge base files.
[0096] Figure 4 This is a schematic diagram of the structure of a file generation processing system provided in an embodiment of this application. Figure 4 As shown, the file generation processing system 400 may include a memory 401 and a processor 402. The memory 401 is configured to store instructions. The processor 402 is configured to retrieve instructions from the memory 401 and, when executing the instructions, to implement the file generation processing method described above.
[0097] This application also provides a computer-readable storage medium storing a program that can be loaded by a processor and executed by any of the file generation processing methods in this application.
[0098] Since the instructions stored in the document generation processing device, processing system, and computer-readable storage medium can execute the steps in any of the document generation processing methods provided in the embodiments of this application, the beneficial effects that any of the document generation processing methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0099] Those skilled in the art will understand that all or part of the functions of the various methods in the above embodiments can be implemented by hardware or by computer programs. When all or part of the functions in the above embodiments are implemented by computer programs, the program can be stored in a computer-readable storage medium, which may include: read-only memory, random access memory, disk, optical disk, hard disk, etc., and the program is executed by a computer to achieve the above functions. For example, the program can be stored in the memory of a device, and when the program in the memory is executed by the processor, all or part of the above functions can be achieved. In addition, when all or part of the functions in the above embodiments are implemented by computer programs, the program can also be stored in a server, another computer, disk, optical disk, flash drive, or external hard drive, etc., and can be downloaded or copied to the memory of a local device, or the system of the local device can be updated. When the program in the memory is executed by the processor, all or part of the functions in the above embodiments can be achieved.
[0100] The above examples illustrate this application only to aid understanding and are not intended to limit its scope. Those skilled in the art to which this application pertains can make various simple deductions, modifications, or substitutions based on the ideas presented.
Claims
1. A method for generating files, characterized in that, include: Extract the first target data to be processed from the first document; Semantic tags are added to the first target data through semantic analysis to generate the second target data; Based on the semantic tags of the second target data, a target mapping model matching the second target data is selected from a plurality of preset mapping models. The mapping model is constructed based on the mapping relationship between multiple types of data sources and multiple types of semantic tags. Based on the target mapping model, a third target data that has a mapping relationship with the second target data is determined from the target data source.
2. The processing method according to claim 1, characterized in that, The step of extracting the first target data to be processed from the first document includes: The first document is parsed, and the element data in the first document whose format attributes match the preset format attributes are used as annotation data; Based on the structural relationship of preset nodes in the first document, determine the associated data that has a semantic relationship with the labeled data; The labeled data and the associated data are integrated to obtain the first target data.
3. The processing method according to claim 2, characterized in that, The preset nodes include sections and paragraphs. The step of determining the associated data with semantic relationships to the labeled data based on the structural relationships of the preset nodes in the first document includes: Obtain the element type and target paragraph to which the labeled data belongs; If the element type of the labeled data is a target type, then the paragraph data in the adjacent paragraphs that have a semantic relationship with the target paragraph are extracted as the first associated data of the labeled data; Based on the target paragraph and the target section to which the target paragraph belongs, structural data of the annotation data is generated, and the structural data is used as the second associated data in the annotation data; The first associated data and the second associated data are integrated to obtain the associated data that has a semantic relationship with the labeled data.
4. The processing method according to claim 3, characterized in that, The process of integrating the labeled data and the associated data to obtain the first target data includes: Using the target section as the first level, associate the section identifier, title data, and page attributes of the target section; Using the target paragraph as the second level, associate the paragraph index, style attributes, and section identifier of the target paragraph; The element data included in the target paragraph is used as the third level, and the content data, element type, and format attributes of the element data are recorded. The data from the first, second, and third levels are integrated based on a set hierarchical order to obtain the first target data.
5. The processing method according to claim 2, characterized in that, The step of adding semantic tags to the first target data through semantic analysis to generate the second target data includes: Based on the element types in the first target data, determine the content characteristics of the first target data; Based on a pre-built knowledge base, semantic tags corresponding to the content features are generated according to the rules corresponding to the element types. The semantic tags are added to the first target data to generate the second target data.
6. The processing method according to claim 1, characterized in that, The step of selecting a target mapping model that matches the second target data from a set of preset mapping models based on the semantic tags of the second target data includes: Based on the semantic tags, semantic analysis is performed on the second target data to obtain semantic analysis results, which include structured indicators, intent tags, and relationship descriptions. The semantic analysis results are used as the context of the second target data and input into a pre-trained large language model to obtain the demand classification of the second target data. Based on the aforementioned requirement classification, a target mapping model matching the second target data is determined.
7. The processing method according to claim 6, characterized in that, The target mapping model includes a tool call mapping model and a source file mapping model. The step of determining the third target data that has a mapping relationship with the second target data from the target data source based on the target mapping model includes: If the target mapping model is a tool-invoked mapping model, then the first key data in the second target data is determined by the semantic label; The first key data is used as context and input together with the first prompt word into the large language model to determine the target tool that matches the second target data, and the first path and tool parameters of the target tool are mapped to the second target data. If the target mapping model is a source file mapping model, then the second key data in the second target data is determined, and a second prompt word is generated; The first fragment of the source file obtained through semantic slicing is used as context and input together with the second prompt word into the large language model to determine the target source file that matches the second target data, and to map the second path and first association field of the target source file with the second target data; and If no target source file corresponding to the second target data is matched in the source file, the target mapping model is determined to be a knowledge base mapping model, and a third prompt word is generated based on the second key data in the second target data. The second fragment of the knowledge base file obtained through semantic slicing is used as context and input together with the third prompt word into the large language model to determine the target knowledge base file that matches the second target data, and the third path and the second association field of the knowledge base file are mapped to the second target data.
8. The processing method according to claim 1, characterized in that, Also includes: Multiple reference files are acquired and converted into a target format, the reference files including source files and knowledge base files, and the target format is a structured format that meets the conditions for semantic analysis; The reference file in the target format is semantically sliced to obtain multiple first semantic segments; Multiple first semantic segments are sequentially input into a pre-trained large language model, and the presence of a semantically missing first semantic segment is determined based on the contextual semantic segments. If the first semantic segment has semantic missing parts, the first semantic segment is concatenated with the context semantic segment to obtain an extended semantic segment, and the extended semantic segment is input into the large language model for iterative judgment of semantic missing parts; In response to the determination that the extended semantic fragment does not have semantic missing, the extended semantic fragment is identified as the second semantic fragment of the reference document, the second semantic fragment including the first fragment of the source document and the second fragment of the knowledge base document.
9. A document generation processing apparatus, characterized in that, include: The extraction module is used to extract the first target data to be processed from the first document; The generation module is used to add semantic tags to the first target data through semantic analysis to generate the second target data; The selection module is used to select a target mapping model that matches the second target data from a plurality of preset mapping models based on the semantic tags of the second target data. The mapping model is constructed based on the mapping relationship between multiple types of data sources and multiple types of semantic tags. The determination module is used to determine, based on the target mapping model, a third target data that has a mapping relationship with the second target data from the target data source.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program that can be loaded by a processor and executed as a file generation processing method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Enhanced document generation and retrieval method based on knowledge graph
CN119646178A
Multi-dimensional product information analysis, management, and application systems and methods
WO2022087497A1