File generation processing method, processing device, and storage medium
By performing semantic analysis and mapping model construction during the file generation process, the problems of information loss and error caused by different data source formats are solved, and efficient and accurate file generation is achieved.
Patent Information
- Application Number
- CN202511457178.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-13
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2045-10-13
AI Technical Summary
Traditional document generation tools suffer from missing information, insufficient accuracy, and misunderstanding of context due to the different formats of data sources, making it impossible to match the format specifications and professional requirements of the original template.
By extracting target data from the first document, performing semantic analysis to add semantic tags, constructing a mapping model between multiple types of data sources and semantic tags, selecting the matching target mapping model, determining associated data from the target data source, reducing blind retrieval, and improving the accuracy and versatility of document generation.
It improves the accuracy and universality of document generation, reduces missing information and errors, and ensures the efficiency and accuracy of data source association.
Smart Images

Figure CN120930596B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to a file generation processing method, a processing device and a storage medium. BACKGROUND
[0002] The traditional file generation tool usually converts the reference file into Markdown format first, then takes the Markdown format file as the context for the Large Language Model (LLM) to understand and process, and outputs the generated document through the dialogue box. In the file generation process, due to the different formats of reference files from different data sources, it is easy to cause the loss of extracted information, insufficient precision of extracted information, and incorrect context understanding, etc., resulting in that the replaced file cannot match the format specification and professional requirements of the original template. SUMMARY
[0003] The purpose of the present application is to provide a file generation processing method, a processing device and a storage medium to solve the problem of low precision of traditional file generation.
[0004] In order to achieve the above purpose, the first aspect of the present application provides a file generation processing method, comprising:
[0005] extracting first target data to be processed from a first document;
[0006] adding semantic labels to the first target data through semantic analysis to generate second target data;
[0007] selecting a target mapping model matched with the second target data from a plurality of preset mapping models based on the semantic labels of the second target data, the mapping model being constructed based on the mapping relationship between a plurality of types of data sources and a plurality of types of semantic labels;
[0008] determining third target data having a mapping relationship with the second target data from a target data source based on the target mapping model.
[0009] The second aspect of the present application provides a file generation processing device, comprising:
[0010] an extraction module configured to extract first target data to be processed from a first document;
[0011] a generation module configured to add semantic labels to the first target data through semantic analysis to generate second target data;
[0012] The selecting module is configured to select a target mapping model matching the second target data from a plurality of preset mapping models based on the semantic label of the second target data, the mapping model being constructed based on mapping relationships between a plurality of types of data sources and a plurality of types of semantic labels.
[0013] The determining module is configured to determine third target data having a mapping relationship with the second target data from a target data source based on the target mapping model.
[0014] The third aspect of the present application provides a computer readable storage medium, the computer readable storage medium stores a program, the program can be loaded by a processor and execute the above-mentioned file generation processing method.
[0015] The beneficial effects of the present application are:
[0016] The present application adds a semantic label to the first target data through semantic analysis, generates second target data containing the semantic label, adds a clear semantic attribute to the data, and provides accurate data basis for subsequent mapping matching, solving the matching error caused by semantic ambiguity in traditional data extraction. The present application further constructs a plurality of preset mapping models based on a plurality of types of data sources and a plurality of types of semantic labels. Then, based on the semantic label of the second target data, a target mapping model matching the second target data is selected to determine third target data having a mapping relationship with the second target data from a target data source. In this way, blind search of the data source can be reduced, the efficiency of determining associated data from the data source is improved, and a plurality of mapping models can adapt to different types of data sources in different scenarios, improving the universality and accuracy of file generation.
[0017] Other features and advantages of the present application will be described in detail in the subsequent specific embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0018] Figure 1 A flowchart of a file generation processing method provided in an embodiment of the present application;
[0019] Figure 2 A flowchart of a file generation processing method provided in an embodiment of the present application;
[0020] Figure 3 A structural diagram of a file generation processing device provided in an embodiment of the present application;
[0021] Figure 4 A structural diagram of a file generation processing system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] With reference to the drawings and the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments of the present application, any other embodiments obtained by a person of ordinary skill in the art without creative effort are within the scope of the present application.
[0023] In the description of the present application, the terms "first", "second" are used only for the purpose of description, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "multiple" is two or more, unless otherwise explicitly and specifically limited. In the present application, the word "exemplary" is used to mean "serving as an example, instance, or illustration". Any embodiment described as "exemplary" in the present application is not necessarily to be construed as preferred or advantageous over other embodiments. The following description is given to enable any person skilled in the art to implement and use the present application. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can realize the present application without using these specific details. In other examples, well-known structures and processes will not be described in detail to avoid unnecessary details making the description of the present application obscure. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the broadest scope consistent with the principles and features disclosed.
[0024] Figure 1 A flowchart of a processing method for generating a file is provided in the embodiments of the present application. As shown in Figure 1 the processing method can include steps 101-104, which will be described in detail below.
[0025] Step 101, extracting first target data to be processed from a first document.
[0026] In the embodiments of the present application, the first document refers to a template document for generating a file, which is used to standardize the format and content framework of the generated file. The first document can include fixed structure and format, and content that needs to be filled or replaced, i.e. first target data. The first target data refers to the content segment extracted from the first document that needs further processing, which 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, which defines the format and scope of the generated file, and the first target data is the specific data content that needs to be processed, which together constitute the initial input basis for file generation.
[0027] Step 102, adding a semantic label to the first target data through semantic analysis to generate second target data.
[0028] In the embodiments of the present application, the semantic label refers to a structured identification added to the first target data through semantic analysis to describe the attribute and processing requirements of the first target data, so as to convert the ambiguous semantics of the first target data into explicit semantic information and clarify the subsequent processing direction. The second target data is the first target data to which the semantic label is added. Subsequently, the efficiency of determining the requirements of the first target data can be improved by analyzing the semantic label of the second target data. In this way, a data basis with clear semantics and clear direction is provided for subsequent data processing.
[0029] Step 103, selecting a target mapping model matching the second target data from a plurality of preset mapping models based on the semantic label of the second target data, the mapping model being constructed based on the mapping relationship between a plurality of types of data sources and a plurality of types of semantic labels.
[0030] In the embodiments of the present application, the mapping model is a rule set for describing the association relationship between a specific type of semantic label and a data source. Through the mapping model, the semantic requirements corresponding to the semantic label can be connected with the source file that can provide data. The mapping model can cover the rules of multiple scenarios, thereby solving the problem of different association logic of different types of data. As an example, the mapping model can be trained by historical data to establish association rules between different semantic labels and data sources. Taking the pharmaceutical field as an example, the "process parameter" type semantic label can be associated with "production record database" and "device operation manual library".
[0031] The target mapping model is the most matching mapping model selected from the plurality of mapping models based on the semantic label of the second target data, thereby improving the accuracy and efficiency of data association. As an example, the mapping relationship between the semantic label and the data source included in each mapping model can also be assigned a corresponding weight, and the mapping model with the highest weight is selected as the target mapping model by matching the applicable label range of each mapping model.
[0032] By presetting a plurality of mapping models, different scenarios can be covered, and the problem of insufficient adaptability of a single model is solved, thereby enhancing the universality of the generation requirements of diversified files. Based on the semantic label, the target mapping model matching the second target data is selected, which can reduce blind search of the data source and improve the efficiency of data source positioning.
[0033] Step 104, determining third target data having a mapping relationship with the second target data from a target data source based on the target mapping model.
[0034] In the embodiment of the present application, the third target data is data that is filtered out from the target data source based on the rule of the target mapping model and has a semantic association with the second target data. The target data source is a data source that is determined by the target mapping model to match the semantic label of the second target data. The third target data can meet the processing needs of the second target data, such as supplement, replacement, matching, and verification, etc. 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 file generation, and improving the accuracy of data association, so that the first document can be converted from a template framework to be processed into a complete document containing accurate information.
[0035] The embodiment of the present application adds a semantic label to the first target data through semantic analysis to generate second target data containing a semantic label, adds a clear semantic attribute to the data, and provides accurate data basis for subsequent mapping matching, solving the matching error caused by semantic ambiguity in traditional data extraction. The embodiment of the present application also constructs a preset mapping model based on multiple types of data sources and multiple types of semantic labels. Then, based on the semantic label of the second target data, a target mapping model matching the second target data is selected to determine third target data having a mapping relationship with the second target data from the target data source. In this way, blind retrieval of the data source can be reduced, the efficiency of determining associated data from the data source is improved, and multiple mapping models can adapt to different types of data sources in different scenarios, improving the generality and accuracy of file generation.
[0036] The embodiment of the present application first needs to extract the data to be processed in the first document, but if only the labeled part of the data is extracted, it is easy to appear incoherent information or logical errors, etc. Therefore, in step 101, the first target data to be extracted not only retains the original logic of the first document, but also focuses on the key content to be processed.
[0037] Based on this, in step 101, the first document can be parsed first, and the element data in the first document that matches the preset format attribute is taken as the labeled data.
[0038] The parsing of the first document refers to structured parsing of the first document, identifying underlying format information and content of the first document through a document parsing tool. Taking the first document as a Word document as an example, the Word document can be parsed into a structured document. As an example, element data can be identified through an OpenXML parser, as well as font styles, paragraph layouts, element types, placeholders, etc. corresponding to the element data. Element data refers to the smallest content unit with independent format attributes in a document, for example, a sentence, a table cell, and a placeholder tag, etc. Format attributes refer to format characteristics of element data, such as font color, background color, font style, special mark, and style name, etc.
[0039] In the first document, fixed data can be used as template information that does not change, and data that needs to be processed can be annotated according to preset format attributes. For example, the preset format attribute can be set as a yellow background. Then, the element data with a yellow background in the first document is annotated as annotated data. Through automatic matching of format attributes instead of manual screening, the situation of missed detection or misjudgment can be reduced, and the recognition efficiency of annotated data is improved.
[0040] In step 101, based on the structural relationship of the preset node in the first document, associated data having a semantic relationship with the annotated data is determined.
[0041] In an embodiment of the present application, the preset node refers to a structured unit preset in the first document. The structural relationship of the preset node can include a hierarchical nesting relationship or a sequential relationship, etc. In an example, the preset node can include sections and paragraphs. The structural relationship between sections or paragraphs can be a sequential relationship, for example, paragraph A precedes paragraph B. The relationship between sections and paragraphs can be a hierarchical nesting relationship, such as a paragraph belonging to a section.
[0042] Based on the structural relationship of the preset node, the associativity between element data in the first document can be inferred. Therefore, the context information of the annotated data can be assisted to understand based on the structural relationship of the preset node, so as to determine associated data having a semantic relationship with the annotated data. For example, if the annotated data is a paragraph of a table, the table title of the previous paragraph is usually needed as the associated data having a semantic relationship. In this way, the semantic fragmentation problem caused by traditional isolated data extraction can be solved, and a more complete semantic environment is provided for subsequent semantic analysis.
[0043] As an example, the element type of the annotation data and the target paragraph to which the annotation data belongs can be obtained first. The element type refers to the content attribute classification of the element data, which is used for the nature of the element data. The target paragraph refers to the specific paragraph of the annotation data in the first document, which can be determined by the paragraph index. By obtaining the attributes and positions of the annotation data, a basis can be provided for the subsequent extraction of associated data, so that different extraction logics are adopted for different types of annotation data, thereby improving the accuracy of the extraction of associated data.
[0044] If the element type of the annotation data is a target type, the paragraph data in the adjacent paragraph having a semantic relationship with the target paragraph is extracted as the first associated data of the annotation data. The target type refers to an element type that needs to be semantically supported by the context. The first associated data is data used to semantically support the annotation data, which is used to supplement the context information of the annotation data. Based on the semantic coherence rule, the associated data needs to be associated in the context paragraph of the target paragraph, and the paragraph data in the paragraph having a semantic relationship with the target paragraph is taken as the first associated data of the annotation data. For example, the picture type needs to extract the corresponding picture description, and the table type needs to extract the table name.
[0045] Then, based on the target paragraph and the target section to which the target paragraph belongs, the structural data of the annotation data is generated, and the structural data is taken as the second associated data of the annotation data. The target section refers to the highest level structural unit to which the target paragraph belongs, which is the core node in the document hierarchy system. The structural data is the institutionalized information describing the position of the annotation data in the document, which reflects the level of the annotation data in the overall framework. The second associated data is the associated data in the form of structural data, which is used to clearly indicate the hierarchical position of the annotation data. By clearly indicating the position of the annotation data through the structural data, the problem of different meanings of the same term in different document positions can be solved, and a position basis is provided for subsequent data tracing.
[0046] The first associated data and the second associated data are integrated to obtain associated data having a semantic relationship with the annotation data. The first associated data representing the context semantic environment of the annotation data and the second associated data representing the structural position of the annotation data are integrated, which can form dual semantic support of content and structure, so that the associated data can explain the context of the annotation data and clearly indicate the position of the annotation data, thereby providing complete data basis.
[0047] Finally, in step 101, the annotation data and the associated data are integrated to obtain the first target data. The annotation data is the core data to be processed, and the associated data is the context auxiliary information. According to the preset rule, the core content and the associated context are integrated to form a complete structured data unit. In this way, the information fragmentation can be reduced, and the subsequent semantic analysis can be based on the complete context, thereby reducing the misjudgment caused by incomplete input information.
[0048] As an example, the target section can be taken as the first level, and the section identifier, title data and page attribute associated with the target section. The section represents a logical chapter or module in the document (such as "process parameters", "operation steps" and "quality control", etc.), used to organize the lower-level content. As a top-level structural unit, each section can include a unique section identifier (sectionID) and title, containing a list of subordinate paragraphs, tables, pictures, etc. Taking the target section as the highest level, it can be used to define the theme range and location of the first target data. Associating the section identifier corresponding to the target section can determine the location of the first level to which the first target data belongs, associating the title data can determine the theme information of the target section, and associating the page attribute can determine the physical location information of the target section in the document. In this way, the macro theme attribution can be determined, the confusion of similar data under different themes can be reduced, and the page attribute can also facilitate the backtracking of the location of the target section.
[0049] Then the target paragraph is taken as the second level, and the paragraph index, style attribute and belonging section identifier of the target paragraph are associated. The paragraph is an intermediate level between the section and the element data, and each paragraph can be given a unique index value according to the sequential position in each section, used to identify the sequential position of the paragraph in the belonging section. And each paragraph has a corresponding style attribute, such as format attribute, to reflect the structural characteristics of the paragraph. The target paragraph is the paragraph where the first target data is located. By associating the paragraph index and the belonging section identifier of the target paragraph, the section and the paragraph are bound to form a nested structure of section and paragraph, ensuring the coherence of the data structure. The style attribute can assist in judging the semantic weight of the target paragraph, providing contextual clues for semantic analysis.
[0050] Then, the element data included in the target paragraph is taken as the third level, and the content data, element type and format attribute of the element data are recorded. The element data is the bottommost unit, which is used to record the microscopic characteristics of the element data. The content data refers to the content information contained in the element data, and the element type can include text data, picture data and table data, etc., which is used to define the processing requirements of the data. For example, the text data is the actual text content in the paragraph, supports rich text attributes (such as bold, color and highlight, etc.), can be used as the core field of the paragraph, records whether it is marked (such as highlight, underline), and extracts the background color (such as “highlight”: “yellow”). The table data is a structured data container, which is used to represent parameter configuration, bill of materials and process steps, etc., and can be represented in the form of two-dimensional array or object array, including table header and data row. The picture data is an embedded image or chart, with description information and reference path, etc., which can include imageId, src (file path or Base64 encoding), alt (alternative text), caption (caption), etc. The format attribute refers to the format characteristics of the element data, which provides a basis for identifying the marked data.
[0051] Then, the data of the first level, the second level and the third level is integrated based on the set level order to obtain the first target data. For example, the first target data can be nested from top to bottom in the order of the first level, the second level and the third level, forming a tree-structured first target data. Therefore, the first target data contains macroscopic theme, mesoscopic context and microscopic content, which provides complete semantic data and structured data for semantic analysis, and improves the efficiency and accuracy of data processing.
[0052] In step 102, the content characteristics of the first target data can be determined according to the element type in the first target data. The content characteristics are the characteristics of the specific attributes of the elements extracted based on the element type. As an example, the content characteristics can be extracted by the extraction rule corresponding to the element type. Converting the first target data into parseable content characteristics can extract the characteristics based on the element type, reducing the disturbance of irrelevant information.
[0053] Then, combined with the knowledge base constructed in advance, the semantic label corresponding to the content characteristics is generated according to the rule corresponding to the element type. Then, the semantic label is added to the first target data to generate the second target data.
[0054] The knowledge base can include a collection of professional knowledge in the field to which the current document belongs, for example, including a field term library, a rule library, and semantic association rules, etc. The knowledge base integrated with the professional field can solve the problem of insufficient understanding of the professional field by the general semantic model, and improve the accuracy of semantic analysis. For different element types, the corresponding mapping logic of the content features and semantic tags can be performed according to the pre-set content features and semantic tags, so as to find the semantic tags corresponding to the content features. The semantic tags are structured identifiers used to describe the semantic attributes of the first target data.
[0055] As an example, the semantic tags of the section can be generated based on the matching of the theme keywords and the field word table to generate field attribute tags. The semantic tags of the paragraph can be generated based on the function words and feature words to generate intent tags. The semantic tags of the text data can be generated based on the core information to generate entity tags, index tags and processing demand tags. The semantic tags of the table data can be generated based on the type and data features to generate type tag association tags. The semantic tags of the picture data can be generated based on the theme and reference information to generate theme tags and reference tags, etc.
[0056] Based on the preset rules and the knowledge base, the semantic annotation can reduce semantic bias and improve the accuracy of the semantic tags, not only solving the problem of ambiguous data semantics, but also providing understandable, associable and verifiable high-quality data basis for mapping model matching.
[0057] In step 103, the deep semantic features of the second target data can be further mined based on the semantic tags. Specifically, based on the semantic tags, the second target data is subjected to semantic analysis to obtain a semantic analysis result. The semantic analysis result can include structured indexes, intent tags and relationship descriptions. The structured indexes are indexes for quantifying or classifying key attributes in the semantic tags, used to describe the structural features of the second target data, determine key data indexes, definitions and calculation methods. The intent tags can represent the processing requirements of the second target data, for example, by analyzing the paragraphs and titles to infer the purpose and expected effect. The relationship description can describe the association logic of the second target data and other entities, understand the logical association and support of different parts of data. The semantic tags of the second target data are taken as input, and the key information is extracted and converted into structured indexes, intent tags and relationship descriptions through parsing rules. Abstract semantics are converted into specific features, which can facilitate subsequent demand classification.
[0058] Then, the semantic analysis result is input as a context of the second target data to a pre-trained large language model to obtain a requirement classification of the second target data. The context refers to a complete semantic background provided by the semantic analysis result, and is used to assist the large language model in understanding the processing requirement of the second target data. The requirement classification is a classification of which mapping model needs to be called by the second target data, and is used as a basis for selecting the mapping model. With the help of the large language model in understanding complex semantics, the accuracy of the classification can be improved.
[0059] The embodiment of the present application can predefine a mapping relationship between the requirement classification and the mapping model. Therefore, the target mapping model matched with the second target data can be determined based on the requirement classification. As an example, the target mapping model includes a tool calling mapping model and a source file mapping model. For example, if the requirement classification is a process parameter verification type, the source file mapping model can be corresponded. If the requirement classification is a calculation parameter type, the tool calling mapping model can be corresponded. By directly locating the target mapping model through the requirement classification, the calling efficiency of the preset model can be improved, and the consistency with the requirement can be ensured to ensure the accuracy and efficiency of the subsequent third target data association, which is suitable for scenarios with diverse requirements and complex models.
[0060] In step 104, if the target mapping model is a tool calling mapping model, the first key data in the second target data is determined through the semantic label. The first key data is a core parameter extracted from the semantic label of the second target data for calling an external tool, and is an input basis for tool execution. Then, the first key data is input as a context to the large language model together with the first prompt word to determine a target tool matched with the second target data, and a first path and a tool parameter of the target tool are mapped with the second target data. The first prompt word is an instruction for guiding the large language model to select a tool, for example, selecting a tool capable of calculating time from the tool based on the parameter [first key data].
[0061] The target tool is an external tool recommended by the large language model to meet the processing requirement of the second target data. The target tool can be associated with the first path and the tool parameter, the first path is a calling address of the target tool, and the tool parameter is a required input parameter. Through intelligent matching of the large language model, the tool can be applied to a scenario with a large tool library, and automatic calculation can be completed to improve the generation efficiency of the to-be-processed data with calculation requirement.
[0062] If the target mapping model is the source file mapping model, 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 a file name keyword, a content theme, etc. The second prompt word is an instruction for guiding the large language model to locate the matching content from the source file, for example, based on [the second key data], find the standard value from the source file.
[0063] Then, the first segment of the source file obtained by semantic slicing is taken as a context, and the second prompt word is input into the large language model together to determine the target source file matching the second target data, and the second path and the first associated field of the target source file are mapped with the second target data. In order to reduce the limitations of long text processing, the embodiment of the present application needs to perform semantic slicing on the source file to generate segments split according to semantic themes. The first segment is a segment related to the second key data in the source file after semantic slicing. The target source file is a complete file matching the second target data selected from the source file. The first segment is taken as a context and the second prompt word is input into the large language model, which can identify the target source file through semantic matching and return the second path and the first associated field of the target source file. In this way, the target source file can be accurately located, and the semantic consistency of the third target data and the second target data is ensured.
[0064] In the embodiment of the present application, there may be no target source file matching the second target data, and then the model switching logic can be triggered to enable the knowledge base mapping model to find the third target data matching the second target data from the knowledge base. The knowledge base mapping model is used as an alternative mapping model to match data from an industry knowledge base.
[0065] Specifically, 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, 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 for locating data from the knowledge base, for example, based on [the second key data], find the temperature standard from the knowledge base.
[0066] Then, the second segment of the knowledge base file obtained by semantic slicing is input into the large language model as a context together with the third prompt word to determine the target knowledge base file matched with the second target data, and the third path and the second association field of the knowledge base file are mapped with the second target data. The second segment obtained by slicing the knowledge base file according to the knowledge entries can also reduce the amount of data calculation and improve the efficiency and accuracy of matching. The target knowledge base file is determined through structured matching, and the third path and the second association field of the knowledge base file are returned, so that the target knowledge base file can be accurately positioned, and the semantic consistency of the third target data and the second target data is ensured.
[0067] The tool invocation mapping model and the source file mapping model are called through the tool to realize accurate adaptation of different types of data sources. The tool invocation mapping model can be used for calculating data, and the source file mapping model can be used for referencing content. On this basis, the backup solution mechanism of the knowledge base mapping model further improves the coverage and robustness of data matching, and determines flexible and reliable mapping solutions for the third data.
[0068] In the process of data processing through the large language model, due to the length limitation of the large language model, and considering the accuracy of semantic understanding and processing efficiency and other factors, the reference file needs to be sliced. The reference file is a set of files supporting data matching, which can include source files and knowledge base files. Through slicing, each segment can be stored, indexed and called individually, realizing on-demand processing without the need to repeatedly parse all reference files, thereby improving the matching efficiency.
[0069] Specifically, a plurality of reference files can be obtained and converted into a target format. The target format is a structured format that meets the semantic analysis conditions. The target format is a structured format that can be analyzed by semantics, such as Markdown, JSON, XML or a custom key-value pair format, which can meet the semantic analysis requirements of machines. Format conversion is the process of converting unstructured or semi-structured reference files into structured formats to extract semantic elements of the reference files and store them in a structured format.
[0070] Next, the reference file in the target format is subjected to semantic slicing to obtain a plurality of first semantic segments. The first semantic segment is the initial result of slicing the reference file. For example, slicing based on a separation tag. However, slicing based on a separation tag and the like is prone to incomplete semantics. Therefore, the first semantic segment also needs to be subjected to a semantic completion operation to reduce the slicing of missing semantics.
[0071] Based on this, the plurality of first semantic segments can be sequentially input to a pre-trained large language model, and it is determined whether there is a first semantic segment with semantic missing based on the context semantic segment. Semantic missing refers to incomplete information caused by excessive splitting of the first semantic segment, which makes it difficult to express complete semantics. The context semantic segment is a segment that assists in determining whether the current first semantic segment is semantically complete. The large language model is trained based on a corpus, and can identify the language integrity of the current first semantic segment.
[0072] If there is a first semantic segment with semantic missing, the first semantic segment and the context semantic segment are spliced to obtain an expanded semantic segment, and the expanded semantic segment is input to the large language model for iterative judgment of semantic missing. The expanded semantic segment refers to a longer segment obtained by splicing the first semantic segment with semantic missing and the context semantic segment, which is used to supplement the missing semantic information. In the process of completing the first semantic segment, the length of the splicing may not be sufficient, and the expanded semantic segment may still have semantic missing. Therefore, it is necessary to repeatedly judge the semantic missing of the completed expanded semantic segment through the large language model until the semantic of the expanded semantic segment is complete.
[0073] In response to determining that the expanded semantic segment does not have semantic missing, the expanded semantic segment is determined as a second semantic segment of the reference file. The second semantic segment is a final segment with complete semantics obtained after semantic missing detection and expansion. The second semantic segment can include the first segment of the source file and the second segment of the knowledge base file. The length of the second semantic segment is adapted to the large language model and the semantics is complete, which provides more accurate reference files for data matching and improves the efficiency of data matching.
[0074] Taking the conversion of the reference file into Markdown format as an example, the reference file in Markdown format is semantically sliced according to paragraphs and title levels to obtain first semantic segments, ensuring that each first segment has a relatively independent structure and theme. Subsequently, the first semantic segments are input into the large language model, and the large language model judges whether the content is complete based on the context semantics.
[0075] If the model identifies that the current first semantic segment has semantic missing (such as unclear reference, missing premise condition, and incoherent logic), it is automatically spliced with the previous first semantic segment (preceding context) and the next first semantic segment (subsequent context) to form a text block containing complete context. The spliced text block is re-input into the large model for semantic integration and completion to generate a second semantic segment with coherent semantics and complete logic. In this way, understanding bias caused by isolated segments can be effectively reduced, ensuring that key information is accurately analyzed in a complete context and improving the accuracy of subsequent knowledge extraction, classification, and application.
[0076] In the embodiment of the present application, when the third target data having a mapping relationship with the second target data is determined from the target data source, the mapping relationship between the third target data and the first target data and / or the second target data can be displayed on the display interface. The user can check and correct on the interface, and complete the mapping between the third target data and the first target data in the file generation.
[0077] The following takes the file generation of the process specification in the pharmaceutical industry as an example. It is assumed that the production process specification of a drug is being modeled, the source files involved include process information table, outsourcing material information, supplier directory and post operation specification, and the density calculation tool needs to be called. Figure 2 The flowchart of the processing method of the file generation provided in an embodiment of the present application is shown in FIG. 1. As shown in the figure, the method can include steps 201 to 208. Figure 2
[0078] Step 201, extracting first target data from a first document.
[0079] It is assumed that the first document is a Word document template with a bottom color label, which includes key parameters (such as temperature, time, pressure, etc.) of the process specification. OpenXML technology can be used to extract the content with specific bottom color label and convert it into a JSON string. For example, the requirement of “the reaction kettle operating temperature needs to be kept between 70-80 degrees” is extracted.
[0080] Step 202, adding semantic labels to the first target data through semantic analysis to generate second target data.
[0081] The extracted JSON is input as context into a large language model for semantic analysis, identifying and classifying different parts of the template, and outputting a new JSON structure. For example, input the extracted JSON into a large language model, and the large language model performs semantic understanding analysis. The prompt word input can be: You are an intelligent document analysis assistant in the field of pharmaceutical production. Based on the following structured JSON content extracted from the process procedure, please conduct in-depth semantic understanding analysis, including: A. Identify data index meaning: analyze key parameters in text and tables, clarify their definition, unit, control range, and whether they are Good Manufacturing Practice (GMP), critical process parameters (CPP), and critical quality attributes (CQA); B. Understand intent: infer the purpose of each paragraph or chapter (such as guiding operation, ensuring safety, and meeting compliance); C. Logical structure analysis: understand the progressive relationship of "operation conditions → safety precautions → quality control", and determine whether there is a dependency or trigger logic. Please output detailed semantic analysis results as the basis for the next classification. The large language model outputs semantic understanding results, obtaining the second target data containing semantic labels.
[0082] Step 203, perform semantic slicing on the reference file and perform semantic completion to obtain the second semantic segment of the reference file.
[0083] After converting multiple reference files into Markdown format, a large language model can be used for understanding and analysis. Based on the analysis results, determine the data slicing dimension and divide the data to obtain the second semantic segment after slicing.
[0084] For example, based on semantic slicing and context completion of multiple source files, the background explains that a pharmaceutical company needs to process multiple source process documents (Word, PDF) to build an intelligent knowledge base in the system. The original files include: SOP-MFG-101.docx: "Glucose Injection Preparation Operation Procedure"; SOP-QC-205.pdf: "Intermediate Quality Detection Standard". The goal is to convert these documents to Markdown, perform semantic slicing, and ensure that each segment is semantically complete to facilitate subsequent use in question answering, parameter extraction, and system configuration. Step 1: Convert multiple source files to Markdown using automated tools (such as pandoc + pdfplumber) to convert files uniformly to structured Markdown. Example output (SOP-MFG-101.md): # Glucose Injection Preparation Operation Procedure.
[0085] The prompt word for semantic integrity judgment of large language model can be: Please judge whether the following text segment is semantically complete. If there is ambiguity in reference, missing premise or logical break, please answer "missing"; otherwise, answer "complete". Text: "In this step, temperature changes must be monitored to prevent local overheating from causing coking." Large language model output: missing. Reason: The reference "this step" is not clear, and the previous text does not specify whether "this step" refers to dissolution, heating or other operations. The context needs to be combined and completed to identify that chunk_04 has semantic missing, automatically splice the previous slice (chunk_03) and the next slice (if any) to form a complete context: ## 3.2 Temperature control: heat to 80±5℃ and maintain for 30 minutes to promote dissolution. ## 3.3 Notes. In this step, the temperature change must be monitored to prevent local overheating from causing coking. Re-input the spliced content into the large language model, and the prompt word is: Please restated the "notes" part based on the complete context, so that it is semantically independent and clear. The output of the large language model (after completion): During the dissolution process of heating to 80±5℃ and maintaining for 30 minutes, the temperature change must be monitored in real time to prevent local overheating from causing glucose coking. Finally, the final second semantic segment is generated, the original first semantic segment is updated, and the semantically complete version is used for subsequent processing.
[0086] Step 204, based on the semantic label of the second target data, select the target mapping model matching the second target data from the preset plurality of mapping models.
[0087] Then the semantic analysis result is classified by the large language model. The input prompt word can be: Based on the semantic analysis result, classify the requirements (final output). According to the above semantic analysis result, divide the labeled content into the following two categories of requirements: tool invocation class: tasks that need to call external tools or systems to complete, such as formula calculation, format conversion, system interface call, etc.; source file association class: content that needs to establish a mapping relationship with external source files (such as SOP, equipment manual, historical batch record). Please output the structured classification result.
[0088] Step 205, if the target mapping model is a tool invocation mapping model, determine the target tool matching the second target data, and form a mapping between the first path and tool parameters of the target tool and the second target data.
[0089] For parts that need to call calculation tools (such as density calculation), traverse the corresponding JSON node and take the labeled content as the context to analyze and extract the required tools and their parameters through the large language model. For example, calculate the density of a certain batch of drugs.
[0090] Step 206, if the target mapping model is a source file mapping model, determine the target source file matching the second target data, and form a mapping between the second path and the first association field of the target source file and the second target data.
[0091] According to the generated template JSON structure, the second key data that needs to be associated with the source file is automatically screened out, and these second key data are integrated into the prompt word framework. At the same time, the first segment of the sliced source file is taken as the context, and a fine-grained mapping relationship network is constructed through the ability of the large language model.
[0092] Step 207, if the target source file corresponding to the second target data is not matched in the source file, the target mapping model is determined as a knowledge base mapping model, the target knowledge base file matching the second target data is determined, and the third path and the second association field of the knowledge base file are mapped with the second target data.
[0093] For parts that require industry expertise, relevant JSON nodes are traversed and used as query content, and relevant information (such as safety operation specifications for a certain material) is searched in the knowledge base, and the found content is used as the context for further matching.
[0094] 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 in response to a correction operation, correct the mapping relationship.
[0095] Finally, the constructed relationship network is displayed on the interface to the user for checking and necessary manual correction, and after ensuring that all information is accurate, the generation of the final process specification document is completed.
[0096] It should be noted that the data source file is not limited to traditional document formats such as PDF, Word and TXT, but also can use a multi-modal large language model to parse pictures and convert them into Markdown format, and then slice and coarsely segment. In addition, other types of files can also be included in the processing range. In this way, no matter what form the data source is, it can be effectively analyzed and converted.
[0097] Figure 3 A structural schematic diagram of a file generation processing device 300 provided in an embodiment of the present application. As shown in Figure 3As shown, the processing apparatus 300 can include an extraction module 301, a generation module 302, a selection module 303, and a determination module 304. The extraction module 301 is configured to extract first target data to be processed from a first document. The generation module 302 is configured to add semantic labels to the first target data by semantic analysis to generate second target data. The selection module 303 is configured to select a target mapping model matching the second target data from a plurality of preset mapping models based on semantic labels of the second target data, the mapping model being constructed based on mapping relationships between a plurality of types of data sources and a plurality of types of semantic labels. The determination module 304 is configured to determine third target data having a mapping relationship with the second target data from a target data source based on the target mapping model.
[0098] In the embodiments of the present application, the extraction module 301 can include a parsing unit, an association unit, and an integration unit. The parsing unit is configured to parse the first document, and take element data in the first document having a format attribute matching a preset format attribute as annotation data. The association unit is configured to determine associated data having a semantic relationship with the annotation data based on a structural relationship of a preset node in the first document. The integration unit is configured to integrate the annotation data and the associated data to obtain the first target data.
[0099] In the embodiments of the present application, the preset node can include a section and a paragraph. The association unit is further configured to obtain an element type of the annotation data and a target paragraph to which the annotation data belongs; if the element type of the annotation data is a target type, extract paragraph data in a paragraph adjacent to the target paragraph having a semantic relationship with the target paragraph as first associated data of the annotation data; generate structural data of the annotation data based on the target paragraph and a target section to which the target paragraph belongs, and take the structural data as second associated data in the annotation data; and integrate the first associated data and the second associated data to obtain associated data having a semantic relationship with the annotation data.
[0100] The integration unit is further configured to take the target section as a first level, associate a section identifier, title data, and page attributes of the target section; take the target paragraph as a second level, associate a paragraph index, style attributes, and a section identifier to which the target paragraph belongs; take element data included in the target paragraph as a third level, record content data, an element type, and format attributes of the element data; and integrate data of the first level, the second level, and the third level based on a set level order to obtain the first target data.
[0101] The generation module 302 can include a feature determination unit, a label generation unit, and a label adding unit. The feature determination unit is configured to determine a content feature of the first target data according to an element type in the first target data. The label generation unit is configured to generate a semantic label corresponding to the content feature according to a rule corresponding to the element type in combination with a knowledge base constructed in advance. The label adding unit is configured to add the semantic label to the first target data to generate the second target data.
[0102] The selection module 303 can include an analysis unit, a classification unit, and a matching unit. The analysis unit is configured to perform semantic analysis on the second target data based on the semantic label to obtain a semantic analysis result, the semantic analysis result including a structured index, an intent label, and a relationship description. The classification unit is configured to input the semantic analysis result as a context of the second target data to a pre-trained large language model to obtain a demand classification of the second target data. The matching unit is configured to determine a target mapping model matched with the second target data based on the demand classification.
[0103] In the embodiments of the present 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.
[0104] The first mapping unit is configured to, in a case where the target mapping model is the tool call mapping model, determine first key data in the second target data through the semantic label; input the first key data as a context and the first prompt word to the large language model together to determine a target tool matched with the second target data, and form a mapping between a first path and a tool parameter of the target tool and the second target data.
[0105] The second mapping unit is configured to, in a case where the target mapping model is the source file mapping model, determine second key data in the second target data and generate a second prompt word; input a first segment of a source file obtained through semantic slicing as a context and the second prompt word to the large language model together to determine a target source file matched with the second target data, and form a mapping between a second path and a first associated field of the target source file and the second target data.
[0106] The third mapping unit is configured to, in a case where the target source file corresponding to the second target data is not matched in the source file, determine the target mapping model as a knowledge base mapping model, and generate a third prompt word based on the second key data in the second target data; input a second segment of a knowledge base file obtained through semantic slicing as a context and the third prompt word to the large language model together to determine a target knowledge base file matched with the second target data, and form a mapping between a third path and a second associated field of the knowledge base file and the second target data.
[0107] In the embodiment of the present application, the processing device 300 can further include an acquisition module, a slicing module, a judgment module, an expansion module and a response module. The acquisition module is configured to acquire a plurality of reference files and convert them into a target format, the reference files including source files and knowledge base files, and the target format being a structured format meeting semantic analysis conditions. The slicing module is configured to perform semantic slicing on the reference files in the target format to obtain a plurality of first semantic segments. The judgment module is configured to input the plurality of first semantic segments into a pre-trained large language model in sequence, and judge whether there is a first semantic segment with semantic missing based on a context semantic segment. The expansion module is configured to, in the case where there is a first semantic segment with semantic missing, splice the first semantic segment with the context semantic segment to obtain an expanded semantic segment, and input the expanded semantic segment into the large language model for iterative judgment of semantic missing. The response module is configured to, in response to determining that the expanded semantic segment has no semantic missing, determine the expanded semantic segment as a second semantic segment of the reference file, the second semantic segment including a first segment of the source file and a second segment of the knowledge base file.
[0108] Figure 4 A structural schematic diagram of a file generation processing system provided in the embodiment of the present application is shown in FIG. 4. As shown in FIG. 4, the file generation processing system 400 can include a memory 401 and a processor 402. The memory 401 is configured to store instructions. The processor 402 is configured to call the instructions from the memory 401 and implement the file generation processing method described above when executing the instructions. Figure 4
[0109] The embodiment of the present application further provides a computer readable storage medium, which stores a program capable of being loaded by a processor and executing any one of the file generation processing methods provided in the embodiments of the present application.
[0110] Since the instructions stored in the file generation processing device, the processing system and the computer readable storage medium can execute the steps in any one of the file generation processing methods provided in the embodiments of the present application, the beneficial effects of any one of the file generation processing methods provided in the embodiments of the present application can be achieved, which are described in detail in the foregoing embodiments and will not be described here again.
[0111] Those skilled in the art can understand that all or part of the functions of various methods in the above embodiments can be realized by hardware or by a computer program. When all or part of the functions in the above embodiments are realized by a computer program, the program can be stored in a computer readable storage medium, which can include a read-only memory, a random access memory, a magnetic disk, an optical disk, a hard disk, and the like. The above functions are realized by executing the program by a computer. For example, the program is stored in a memory of a device, and when the program in the memory is executed by a processor, the above functions are realized. In addition, when all or part of the functions in the above embodiments are realized by a computer program, the program can also be stored in a storage medium such as a server, another computer, a disk, an optical disk, a flash disk, or a mobile hard disk, and is downloaded or copied into a memory of a local device or is updated in version to a system of the local device. When the program in the memory is executed by a processor, all or part of the functions in the above embodiments are realized.
[0112] The above application is described by using specific examples, which is only used to help understand the application and does not limit the application. According to the idea of the application, those skilled in the art can make several simple deductions, modifications, or substitutions.
Claims
1. A processing method of file generation, characterized by, The method comprises: extracting first target data to be processed from a first document; adding a semantic label to the first target data through semantic analysis to generate second target data; selecting a target mapping model matching the second target data from a plurality of preset mapping models based on the semantic label of the second target data, the mapping model being constructed based on a mapping relationship between a plurality of types of data sources and a plurality of types of semantic labels, the target mapping model comprising a tool call mapping model and a source file mapping model; if the target mapping model is the tool call mapping model, determining first key data in the second target data through the semantic label; inputting the first key data as a context and a first prompt word into a pre-trained large language model to determine a target tool matching the second target data, and forming a mapping between a first path and a tool parameter of the target tool and the second target data; if the target mapping model is the source file mapping model, determining second key data in the second target data and generating a second prompt word; inputting a first segment of a source file obtained through semantic slicing as a context and the second prompt word into the large language model to determine a target source file matching the second target data, and forming a mapping between a second path and a first associated field of the target source file and the second target data; if no target source file corresponding to the second target data is matched in the source file, determining the target mapping model as a knowledge base mapping model, and generating a third prompt word based on the second key data in the second target data; inputting a second segment of a knowledge base file obtained through semantic slicing as a context and the third prompt word into the large language model to determine a target knowledge base file matching the second target data, and forming a mapping between a third path and a second associated field of the knowledge base file and the second target data. The method comprises:
2. The treatment method according to claim 1, characterized in that, parsing the first document, and taking element data in the first document with a format attribute matching a preset format attribute as annotation data; determining associated data having a semantic relationship with the annotation data based on a structural relationship of a preset node in the first document; integrating the annotation data and the associated data to obtain the first target data. The preset node comprises a section and a paragraph, and the method comprises:
3. The treatment method according to claim 2, characterized in that, obtaining an element type of the annotation data and a target paragraph to which the annotation data belongs; if the element type of the annotation data is a target type, extracting paragraph data in a neighboring paragraph having a semantic relationship with the target paragraph as first associated data of the annotation data; generating structural data of the annotation data based on the target paragraph and a target section to which the target paragraph belongs, and taking the structural data as second associated data in the annotation data. Integrate the first association data and the second association data to obtain the association data having a semantic relationship with the annotation data.
4. The treatment method according to claim 3, characterized in that, The integrating the annotation data and the association data to obtain the first target data comprises: associating, with the target section as a first level, section identifiers, title data, and page attributes of the target section; associating, with the target paragraph as a second level, paragraph indexes, style attributes, and belonging section identifiers of the target paragraph; associating, with element data included in the target paragraph as a third level, content data, element types, and format attributes of the element data; integrating data of the first level, the second level, and the third level based on a set level order to obtain the first target data.
5. The treatment method of claim 2, wherein The adding semantic labels to the first target data through semantic analysis to generate second target data comprises: determining content features of the first target data according to element types in the first target data; generating semantic labels corresponding to the content features according to rules corresponding to the element types in combination with a pre-constructed knowledge base; adding the semantic labels to the first target data to generate the second target data.
6. The treatment method of claim 1, wherein The selecting, based on semantic labels of the second target data, a target mapping model matching the second target data from a plurality of preset mapping models comprises: performing semantic analysis on the second target data based on the semantic labels to obtain a semantic analysis result, the semantic analysis result comprising a structured index, an intent label, and a relationship description; inputting the semantic analysis result as a context of the second target data into a pre-trained large language model to obtain a demand classification of the second target data; determining the target mapping model matching the second target data based on the demand classification.
7. The treatment method of claim 1, wherein Further comprising: obtaining a plurality of reference files and converting them into a target format, the reference files comprising source files and knowledge base files, and the target format being a structured format meeting semantic analysis conditions; performing semantic slicing on the reference files in the target format to obtain a plurality of first semantic segments; inputting the first semantic segments into a pre-trained large language model in sequence, and judging whether there is a first semantic segment with semantic missing based on a context semantic segment; if there is a first semantic segment with semantic missing, splicing the first semantic segment with a context semantic segment to obtain an expanded semantic segment, and inputting the expanded semantic segment into the large language model for iterative judgment of semantic missing; in response to determining that the expanded semantic segment has no semantic missing, determining the expanded semantic segment as a second semantic segment of the reference file, the second semantic segment comprising a first segment of the source file and a second segment of the knowledge base file.
8. A processing apparatus of file generation, characterized by, comprise: an extraction module configured to extract first target data to be processed from a first document; a generation module configured to add semantic labels to the first target data through semantic analysis to generate second target data; The selecting module is configured to select a target mapping model matching the second target data from a plurality of preset mapping models based on a semantic label of the second target data, the mapping models being constructed based on mapping relationships between a plurality of types of data sources and a plurality of types of semantic labels, and the target mapping model including a tool call mapping model and a source file mapping model; The determining module includes a first mapping unit, a second mapping unit, and a third mapping unit; The first mapping unit is configured to determine first key data in the second target data by the semantic label when the target mapping model is the tool call mapping model; The first key data is input as context to a pre-trained large language model together with a first prompt word to determine a target tool matching the second target data, and a first path and tool parameters of the target tool are mapped with the second target data; The second mapping unit is configured to determine second key data in the second target data and generate a second prompt word when the target mapping model is the source file mapping model; A first segment of a source file obtained by semantic slicing is input as context to the large language model together with the second prompt word to determine a target source file matching the second target data, and a second path and a first associated field of the target source file are mapped with the second target data; The third mapping unit is configured 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 generate a third prompt word based on the second key data in the second target data; A second segment of a knowledge base file obtained by semantic slicing is input as context to the large language model together with the third prompt word to determine a target knowledge base file matching the second target data, and a third path and a second associated field of the knowledge base file are mapped with the second target data. The computer readable storage medium stores a program, which can be loaded and executed by the processor to perform the processing method of the file generation according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that,
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