Batch record table generation method, generation device, and storage medium

By performing row-level semantic vector matching and format attribute extraction on the batch record table, guiding information is constructed, and the target batch record table is automatically generated. This solves the problem of difficulty in balancing format and content in traditional methods, and achieves efficient, accurate and compliant batch record table generation.

CN120930617BActive Publication Date: 2025-12-23CHENGDU HONGRUI TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511457181.5
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

Technical Problem

Traditional batch record generation methods struggle to simultaneously meet the requirements of format accuracy and content precision, resulting in long processing times and a high risk of omissions or errors.

Method used

By slicing historical batch record files by row and extracting sample semantic vectors and storing them in a vector database, slicing template table files by row and extracting format attributes, constructing guiding information, and editing each cell in the template table file based on the editing behavior description, the target batch record table file is generated.

Benefits of technology

The generated target batch record table file ensures that the cell editing content meets semantic and format requirements, reduces semantic misalignment, and improves generation efficiency and compliance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120930617B_ABST
    Figure CN120930617B_ABST
Patent Text Reader

Abstract

The application relates to a batch record form generation method and device and a storage medium. Historical form data of a historical batch record file is sliced according to rows to obtain multi-row sample segment data, a sample semantic vector of each row of sample segment data is extracted and stored in a vector database, a template form file is sliced according to rows to obtain multi-row template segment data, and a format attribute of each row of template segment data is extracted. Then, guide information is constructed according to the vector database, the format attribute of the multi-row template segment data and source document data, and an editing behavior description corresponding to each cell in the template form file is generated based on the guide information, so that each cell in the template form file is edited, and a target batch record form file is generated. In this way, the target batch record form file generated can meet the requirements of format fidelity and content accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, in particular to a batch record form generation method and device and a storage medium. BACKGROUND

[0002] The batch record form is an institutionalized form document that systematically records the key information of the whole-link process of a single batch of target objects, and can associate the quality and production compliance of the target objects. Taking the pharmaceutical industry as an example, the batch record form can include the key information of the whole-link of the raw material input, process execution, parameter monitoring, finished product inspection and release audit of drug production. The batch record form is strongly bound to the production process, completely matches the production business process of the target object, and strictly follows the format requirements and compliance requirements of the professional field.

[0003] The traditional batch record form relying on manual recording needs to create a new batch record form based on a template, fill in the fields line by line by comparing different source documents, which is time-consuming and prone to omissions or errors due to fatigue. The batch record form generated by software usually only generates data in the entire form, and it is difficult to identify the editing requirements of the content of each cell, which is prone to format disorder. Therefore, the traditional generation of batch record forms cannot meet the requirements of format fidelity and content accuracy at the same time. SUMMARY

[0004] The purpose of the present application is to provide a batch record form generation method, device and storage medium to solve the problem that the traditional batch record form generation cannot meet the requirements of format fidelity and content accuracy at the same time.

[0005] To achieve the above purpose, the first aspect of the present application provides a batch record form generation method, comprising:

[0006] Slicing the historical form data of the historical batch record file by rows to obtain multiple row sample segment data, and storing the sample semantic vector of each row of the sample segment data in a vector database;

[0007] Slicing the template form file by rows to obtain multiple row template segment data, and extracting the format attribute of each row of the template segment data;

[0008] According to the vector database, the format attribute of the multiple row template segment data and the source document data, constructing guide information, and generating an editing behavior description corresponding to each cell in the template form file based on the guide information, the guide information including the historical form row, cell semantic description and target text data of each row of the template segment data;

[0009] edit each cell in the template table file based on the edit behavior description, to generate a target batch record table file.

[0010] The second aspect of the present application provides a batch record table generation device, comprising:

[0011] a vector storage module configured to slice historical table data of a historical batch record file by rows to obtain multi-row sample segment data, extract a sample semantic vector of each row of the sample segment data, and store the sample semantic vector in a vector database;

[0012] a structure analysis module configured to slice a template table file by rows to obtain multi-row template segment data, and extract a format attribute of each row of the template segment data;

[0013] an instruction generation module configured to construct guide information according to the vector database, the format attribute of the multi-row template segment data, and source document data, and generate an edit behavior description corresponding to each cell in the template table file based on the guide information, the guide information comprising a historical table row, a cell semantic description, and target text data of each row of the template segment data;

[0014] a file editing module configured to edit each cell in the template table file based on the edit behavior description, to generate a target batch record table file.

[0015] 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 and executed by a processor to perform the batch record table generation method.

[0016] The present application has the following beneficial effects:

[0017] The historical table data of the historical batch record file is sliced by rows in the application to obtain multi-row sample fragment data, and the sample semantic vector of each row of sample fragment data is extracted and stored in a vector database. At the same time, the template table file is sliced by rows to obtain multi-row template fragment data, and the format attribute of each row of template fragment data is extracted respectively. Through row-level semantic vector matching, the compliance content of the same type of historical batch record can be reused. Then, according to the vector database, the format attribute of the multi-row template fragment data and the source document data, the guide information including the historical table row of each row of template fragment data, the cell semantic description and the target text data is constructed, and then the editing behavior description corresponding to each cell is generated based on the guide information. The historical table row can be used as a historical data example for generating the editing behavior description, the cell semantic description can be used as a format function definition for generating the editing behavior description, and the target text data can be used as a compliance content reference for generating the editing behavior description. Finally, based on the editing behavior description, each cell in the template table file is edited, and the target batch record table file can be generated. The generated target batch record table file can ensure that the editing content of the cell conforms to the cell semantics, reduces the semantic misplacement, and the editing content is derived from the source document data, which can ensure the compliance of the editing content. In this way, the generated target batch record table file can meet the requirements of format fidelity and content accuracy at the same time.

[0018] Other features and advantages of the present application will be described in detail in the following specific embodiments. BRIEF DESCRIPTION OF DRAWINGS

[0019] Figure 1 A flowchart of a batch record table generation method provided in an embodiment of the present application;

[0020] Figure 2 A flowchart of an editing behavior description generation method provided in an embodiment of the present application;

[0021] Figure 3 A flowchart of a batch record table generation method provided in an embodiment of the present application;

[0022] Figure 4 A structural diagram of a batch record table generation device provided in an embodiment of the present application;

[0023] Figure 5 A structural block diagram of a batch record table generation system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] 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 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, all the other embodiments obtained by a person of ordinary skill in the art without creative work fall within the scope of the present application.

[0025] In the description of the present application, it should be understood that 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 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. In order to enable any person skilled in the art to implement and use the present application, the following description is given. 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 characteristics disclosed in the present application.

[0026] Figure 1 A flowchart of a generation method of a batch record table provided in an embodiment of the present application is shown. As shown in Figure 1 , the generation method can include steps 101-104, which will be described in detail below.

[0027] Step 101, slice the historical table data of the historical batch record file by rows to obtain multi-row sample fragment data, and store the sample semantic vector of each row of sample fragment data in a vector database.

[0028] The historical batch record file refers to a batch record file that has been archived in a past production process of an enterprise, and can include audited compliance data. The historical table data is a batch record table in the batch record file. Taking a batch record table in the pharmaceutical field as an example, a core feature of the pharmaceutical batch record table is that each row corresponds to an independent business unit, and therefore, embodiments of the present application can slice the historical table data by row to provide historical evidence for content accuracy. Slicing by row refers to an operation of extracting part of continuous or discrete row data along the row dimension from a complete table according to a specific rule or requirement to form an independent segment. Embodiments of the present application locate corresponding physical rows through logical row labels, extract the corresponding physical rows, and retain the format constraint of cell merging information to ensure that the subsequent filled data is format-compliant. The slicing can be based on the dual positioning of semantic features and format features, so as to reduce the amount of calculation and speed up the generation of batch records.

[0029] The sample segment data is the historical table data obtained after slicing by row. For example, a complete table of raw material information rows, sterilization parameter rows, and inspection result rows can be split into three independent sample segments, each row corresponding to a specific business unit and including multiple cells. For example, the sterilization parameter row can include cells of sterilization temperature, time, and pressure.

[0030] The sample semantic vector is a fixed-dimension vector generated by encoding the text content of each row of sample segment data using a pre-trained language model (for example, BERT or RoBERTa), and the vector value represents the semantic features of the row, such as the spatial distance between multiple rows of sample segment data. The vector database is a database that stores all sample segment data and can support efficient vector similarity retrieval.

[0031] Storing the sample semantic vectors of the historical table data by row provides historical evidence for subsequent data matching, and compared with matching at the document level and the table level, the matching content is more accurate. Furthermore, the compliance data of the same batch can be accurately reused, and the content logical consistency of different batch records can be improved.

[0032] Step 102, slice the template table file by row to obtain multiple rows of template segment data, and extract the format attribute of each row of template segment data.

[0033] The template form file is a standardized batch record template formulated by an enterprise according to industry standards (for example, the Good Manufacturing Practice of Medical Products (GMP) in the pharmaceutical industry), which can include a fixed form structure, such as the number of rows, the number of columns, merging rules, font styles, row height and column width, business fields, and the like. Similar to the slicing logic in step 101, splitting the template form into multiple row template segment data according to rows can keep the template row aligned with the sample segment data in terms of granularity, and reduce format confusion caused by cross-business unit editing.

[0034] The format attribute is the format feature of each cell in the template segment data extracted by parsing the underlying structure of the template form file (for example, the OpenXML format of the docx document). In one example, the format attribute can include structural attributes (such as cell merging information, coordinate position, row height and column width), style attributes (such as font type, font size, special mark, etc.), and functional attributes (such as whether it is a mandatory item, etc.). Converting the unstructured format of the template form file into a computable structured format attribute can lay the foundation for subsequent editing format fidelity.

[0035] Step 103, constructing guidance information according to the vector database, the format attribute of the multi-row template segment data, and the source document data, and generating an editing behavior description corresponding to each cell in the template form file based on the guidance information. The guidance information can include the historical form row of each row of template segment data, the cell semantic description, and the target text data.

[0036] The guidance information is an instruction for generating the editing behavior description. For example, for a large language model, the guidance information can be a prompt word. The embodiments of the present application integrate the vector database, the format attribute of the multi-row template segment data, and the source document data to obtain the historical form row of each row of template segment data, the cell semantic description, and the target text data to construct the guidance information. The historical form row can be used as a historical data example for generating the editing behavior description, which is retrieved from the vector database to find a historical row with high semantic similarity to the current row of template segment data. The cell semantic description can be used as a functional definition of the format for generating the editing behavior description, which is generated based on the functional definition of each cell of the format attribute. The target text data can be used as a compliance content reference for generating the editing behavior description, which is the source document required for generating the target batch record file. For example, the pharmaceutical industry can include process procedures and raw material inspection reports. The guidance information contains both the format attribute and the content requirement, which can make the editing behavior description meet the requirements of not being damaged in format and being compliant in content and semantics.

[0037] Based on the guidance information, semantic analysis can be performed on each cell in the target table file to generate structured operation instructions, i.e., edit behavior descriptions. The edit behavior descriptions explicitly describe the editing requirements of each cell. For example, the cells in the 2nd and 3rd columns of the 1st row are merged, and the sterilization temperature 120°C of the source document with ID C-1000 is filled in, and the underline style is maintained. The edit behavior description explicitly records the position of the filled cell and the required cell format, providing data basis for subsequent content and format compliance.

[0038] In step 104, based on the edit behavior description, each cell in the template table file is edited to generate a target batch record table file.

[0039] Based on the edit behavior, precise operations can be performed on the underlying structure of the template table file. For example, the corresponding cell node can be found through the position coordinates of the format attribute to locate the cell that needs to be edited. The target text data is filled in the cell node without modifying the cell format. As an example, after editing, the actual filled format can be automatically compared with the template format attribute, and if there is a deviation, automatic correction operations can also be performed. By modifying only the text and preserving the editing logic of the cell format, it can be ensured that the cell format in the target batch record table file matches the template format, and through the constraints of target text data and cell semantic description, the accuracy and compliance of the edited content can be improved. In this way, both format fidelity and content accuracy can be guaranteed.

[0040] The embodiments of the present application replace manual line-by-line filling of batch record tables with full-process automation, greatly shortening the generation time of batch record tables, and are suitable for production scenarios with multiple varieties and high-frequency words. Through line-level semantic vector matching, the compliant content of historical batch records of the same type can be reused. According to the vector database, the format attributes of the multi-line template segment data, and the source document data, guidance information including the historical table row of each line of template segment data, cell semantic description, and target text data is constructed, and then based on the guidance information, an edit behavior description corresponding to each cell is generated. Finally, based on the edit behavior description, each cell in the template table file is edited to generate a target batch record table file. The generated target batch record table file can ensure that the edited content of the cell conforms to the cell semantics, reduces the semantic misplacement, and the edited content is derived from the source document data, which can ensure the compliance of the edited content. In this way, the generated target batch record table file can meet the requirements of format fidelity and content accuracy at the same time.

[0041] The generation of the edit behavior description is a reasoning process of fusing multiple source data to form structured instructions. In step 103, based on the different guidance information provided by the multiple source data, the goals of format fidelity, content accuracy, and compliance are achieved.Figure 2 FIG. 1 is a flowchart of an embodiment of a method for generating an edit behavior description according to the present disclosure. As shown in FIG. 1, the method for generating an edit behavior description can include steps 101-104, which will be described in detail below. Figure 2

[0042] Step 201: Determine historical table rows having semantic relationships with each row of template fragment data based on a vector database.

[0043] For each row of template fragment data, the text can also be converted into a fixed-dimension semantic text vector by a pre-trained language model. The semantic text vector of each row of template fragment data is input into the vector database, and the similarity between the semantic text vector of the template fragment data and the sample semantic vector of each row of sample fragment data in the vector database is calculated, for example, by calculating the cosine similarity. The similarity-based calculation structure can filter out the required historical table rows. For example, template fragment data with a similarity greater than or equal to 0.8 is filtered as a historical table row.

[0044] Step 202: Determine the cell semantic description corresponding to each cell in each row of template fragment data in combination with the format attribute of each row of template fragment data.

[0045] The format attribute is a set of features describing the appearance and structure of the cell. By analyzing the underlying file structure of the template fragment data, the format attribute of each cell in each row of template fragment data can be extracted. The cell semantic description is a natural language definition of the cell function and filling requirements, which is a functional specification of content filling. In the embodiments of the present disclosure, a mapping relationship between the format attribute and the semantic function can be first constructed based on industry specifications, etc. For example, for the sterilization process key parameters, cross 2 columns are merged, bolded, and located in the sterilization row. For each cell in the template fragment data, the mapping relationship can be matched according to its format attribute to generate a cell semantic description containing position, function, filling specification, compliance attribute, etc.

[0046] Step 203: Analyze the source document data required for generating the target batch record table file, and determine the target text data of each row of template fragment data based on the source document data.

[0047] ​The source document data is the legal basis file and the original data file required for generating the target batch record table file. For example, in the pharmaceutical industry, it can include process procedures, raw material inspection reports, production instruction sheets, and equipment logs, etc. The target text data is the specific content extracted from the source document data that conforms to the cell semantic description, as the data content filled into the cell. The parsing of the source document data can adopt a multi-source processing method to process multiple types of source documents. Then, the target text data in the source document data is matched with each row of template fragment data. In this way, the compliant data can be filtered as the target text data.

[0048] In step 204, the historical table row, cell semantic description and target text data of each row of template fragment data are integrated into a prompt word respectively, and input into a large language model to obtain an editing behavior description corresponding to each cell in each row of template fragment data.

[0049] The editing behavior description in the embodiments of the present application can be generated by a large language model (LLM), and therefore the guidance information can be a prompt word input to the LLM. The prompt word is a structured text input to the LLM, which contains task requirements, reference data, constraint conditions, etc., and is used to guide the LLM to generate a predicted result that meets the expectations. The historical table row, cell semantic description and target text data of each row of template fragment data are integrated into a prompt word in a fixed format, forming a prompt word containing constraint conditions, reference data and target data. Then, an LLM suitable for the current scenario is selected, and the LLM generates a logical editing behavior description by understanding the semantic information in the prompt word.

[0050] The editing behavior description can reduce the problem of destroying the format in traditional editing by retaining the requirements of the explicit format, and converting the format properties of the template into executable editing instructions. Based on the reference of the cell semantic description and the historical table row, the exclusive content rules are bound for each cell, which can reduce the semantic misplacement of content filling errors. By integrating the format, semantics and source, three constraints are provided for the editing operation of each cell, solving the contradiction between keeping the format and keeping the content in traditional batch record table generation, and achieving the precise balance between format and content. Moreover, through the editing behavior description, the editing behavior of each cell can be traced and explained, improving the traceability efficiency.

[0051] In order to more clearly illustrate the generation process of the editing behavior description, the following describes the generation of the historical table row, the cell semantic description and the target text data respectively.

[0052] In step 201, the text content of each row of template segment data can be extracted first and converted into a semantic text vector. The text content is text information reflecting the business meaning of the cell, and converting the text content into a semantic text vector can be achieved by adapting a pre-trained language model fine-tuned for the current industry, so that the semantic relationship between professional terms in the industry can be identified. For example, sterilization and disinfection belong to semantic relationships with strong association.

[0053] Then, the similarity of the semantic text vector and the sample semantic vector in the vector database is calculated. As an example, the sample semantic vector in the vector database can be retrieved by retrieval-augmented generation (RAG), and the similarity between the semantic text vector and the sample semantic vector is calculated. For example, the cosine similarity of the two is calculated, and the closer the result is to 1, the more similar the business logic is. The embodiments of the present application can be based on a threshold value set based on business logic and historical data, i.e., a similarity threshold is set, which is used to filter out candidate table rows that are similar enough to the template semantics. The sample segment data corresponding to the sample semantic vector with a similarity greater than the set similarity is filtered out as a candidate table row. For example, the top 10 sample segment data with the highest similarity can be recalled as candidate table rows and entered into the candidate context pool.

[0054] The candidate table row can contain a small number of interference terms that are semantically similar but do not match the current business. Therefore, in order to eliminate candidate table rows that are semantically similar but irrelevant to the business, the candidate table rows also need to be subjected to semantic verification of keywords, and the candidate table rows that pass the semantic verification are used as historical table rows. The semantic verification of keywords can ensure that the historical table rows belong to the same business scenario as the template segment data. Specifically, the core keywords of the business can be extracted from the template segment data, representing the core business scenario of the row. For example, sterilization temperature, sterilization time, etc., can determine the core business scenario of this row as sterilization. Similarly, the candidate table row can also extract keywords that match the core keywords of the template segment data, and the candidate table row that passes the semantic verification is retained as the final historical table row. In one example, a prompt word can be constructed based on the candidate table row and the current semantic text vector, input to the LLM for semantic matching judgment, and the most similar historical table row is selected as the context basis for generating this part.

[0055] Through the double screening of semantic vectors and keyword verification, the problem of missing synonymous terms in keyword matching can be reduced, and at the same time, interference terms that are semantically similar but irrelevant to the business can be eliminated, ensuring that the historical table rows belong to the same business unit as the row of template segment data, and thus the accuracy of batch record content is guaranteed from the source.

[0056] In step 202, the template table file can be first converted into an image format and visual format features are extracted, and a multi-modal prompt word is constructed combining the semantic text vector of each row of template segment data.

[0057] The image format refers to a format that retains the visual layout features of the table, such as JPG, PNG, etc. The visual format features are features extracted from the template table file in image format that can reflect the visual layout and style of the table, which can include structural features and style features. In one example, the template table file (e.g., a template table file in docx format) can be converted into a high-resolution image (e.g., a 300 dpi PNG) through a rendering engine to ensure that the image completely retains the visual details of the table. Then, through computer vision algorithms such as object detection or image segmentation, etc., the visual format features are extracted from the template table file in image format. For example, structural features are extracted with an edge detection algorithm or font style is identified with pixel value, etc. The multi-modal prompt word is a prompt word that fuses text information and image information, which can include language semantics and visual layout information. Integrating the semantic text vector of the template segment data and the visual format features can generate a multi-modal prompt word.

[0058] Then, the multi-modal prompt word is input into a visual language large model to obtain the format attribute of each cell in the template segment data and the corresponding cell semantic description. The visual language large model is an artificial intelligence model that can understand both text semantics and image visual features. Through training of multi-modal data of text and image, it can have the ability to parse table layout and correlate text and format. For example, GPT-4V or LayoutLMv3, etc.

[0059] As an example, the format attribute of each row of template segment data can be parsed to extract format features. The format features are features of structured format attributes extracted from the template segment data, which can include cell merging information, font style markers, and cell position coordinates.

[0060] Then, semantic mapping rules are constructed based on the format features. The semantic mapping rules are mapping relationships between format features and cell functions based on the business logic of the industry, which can connect format and semantics. For example, a merged cell can correspond to an overall semantic label, which can span multiple rows or columns. Bold font cell markers can correspond to key parameter items, and position coordinates are mapped to business. Finally, according to the semantic mapping rules, the corresponding cell semantic description is generated for each cell. If there is a deviation, it can be actively corrected with the semantic mapping rules to ensure that the semantic description and format features are satisfied at the same time.

[0061] By converting the template table file into a picture format, the recognition blind spot of traditional table files for some formats can be solved, and the integrity of format feature extraction can be improved. Moreover, by simultaneously inputting text semantics and visual format, the accuracy of each cell can be improved, and the semantic misplacement situation can be reduced. Complete format attributes can also provide rigid constraints for subsequent editing behavior description, reducing the situation of subsequent editing destroying the template structure.

[0062] In step 203, the source document data required to generate the target batch record table file can be structured parsed to extract multi-type data. Structured parsing refers to the process of converting unstructured or semi-structured source document data into structured data (such as key-value pairs) that can be recognized by machines. After parsing, multi-type data can be obtained, which can include entity data, rule data, and association data. Entity data refers to specific business values or text, rule data refers to specifications that constrain entity data, and association data refers to corresponding relationships between entity data.

[0063] Differentiated processing methods can be used for source document data of different formats. For example, for scanned or picture-based documents, high-precision optical character recognition (OCR) technology can be used to recognize text. Electronic documents can be directly extracted by a document parsing library to retain chapter levels. Semi-structured documents can directly read cell data and associate metadata such as timestamps. Multi-type data extraction can be based on natural language processing (NLP) classification to extract data. Storing multi-type data in a relational database and establishing an index can facilitate subsequent rapid retrieval.

[0064] Next, the corresponding source document field label is matched for each row of template fragment data. The source document field label is a classification label defined based on the business scenario of the template fragment data, for example, it can include sterilization parameters, raw material information, etc., and is used to associate each row of template fragment data with the corresponding business data in the source document data. Therefore, the source document field label has a mapping relationship with the associated business scenario and the source document data type, based on which a source document field label library can be constructed in advance, which can cover all business scenarios of the batch record table file. The semantic vector of each row of template fragment data and the source document field label library is calculated for similarity, the label with the highest similarity is selected as the source document field label of the row of template fragment data, and then the field label is associated with the identification of the row where the template fragment data is located, providing data basis for subsequent retrieval.

[0065] Further based on the source document field label, multi-type data is retrieved, and candidate text data matching the cell semantic description of each row of template segment data is screened from the structured parsed source document data. Based on the source document field label, entity data associated with the template segment data can be preliminarily retrieved, and then for the cell semantic description of each row of template segment data, the retrieved entity data can be secondarily screened to ensure that the data matches the function of the cell.

[0066] Finally, the candidate text data is subjected to compliance verification, and the candidate text data passing the compliance verification is determined as the target text data. As an example, the compliance verification can include format verification, threshold verification, and association verification. The format verification is to verify whether the format of the candidate text data is standard based on the rule data. The threshold verification is to verify whether the numerical value type candidate text data is within the threshold range specified by the rule data. The association verification is to verify whether the association of the candidate text data with other data is consistent according to the association data. The candidate text data passing the three types of verification can be determined as the target text data. Meanwhile, for partial compliance, such as unqualified data in format or association verification, the data can be automatically corrected and re-verified. For serious non-compliance, such as threshold exceeding, human intervention is triggered for prompting, and after human confirmation, it is determined whether the data can be used as the target text data. The compliant target text data can be associatedly stored with the identifier of the row where the template segment data is located, the identifier of the cell, and the like.

[0067] The source document data is structured parsed in multiple ways to convert unstructured source document data such as scanned copies and pure text into structured data, improving the efficiency of data extraction. The row identifier is associated with the source document data, and combined with the secondary screening of the cell semantic description, the semantic misplacement problem can be reduced, and the accuracy of data matching can be improved. Through multiple verification methods, data that does not comply with industry standards can be eliminated, reducing the problem of batch record audit failure caused by data violation, and improving the compliance of data. The target text data is associated with the source of the source document data and the rule basis, which can provide a basis for subsequent generation of editing behavior description, ensuring that the batch record table data has a source and is traceable and rule-based, meeting the audit traceability needs of strong compliance industries.

[0068] In step 104, the editing behavior description can be first structured parsed to extract editing instruction parameters. The structured parsing is a process of converting unstructured data in the editing behavior description into machine-recognizable key-value pair parameters through a rule engine or an NLP model. The editing instruction parameters are parameters required by the instructions of the extracted editing operation after parsing. As an example, the editing instruction parameters can include cell positioning information, operation type, content to be edited, and format constraint. The cell positioning information specifies the specific location of the editing object. The operation type refers to the specific operation action of editing the cell. The content to be edited is the specific data that needs to be filled into the cell, associated with the source document data. The format constraint refers to the format requirement that needs to be retained during editing. After structured parsing, it can be checked whether the parameters are complete, and if there is a missing, the default format attribute of the template is automatically supplemented.

[0069] Then, based on the format attribute of the template segment data, the target node position corresponding to each cell positioning information is determined. The target node position refers to the specific data node in the underlying file structure of the template segment table corresponding to the cell positioning information. For example, for the docx format, the document.xml in the compressed package can be read to identify <w:tbl>For table nodes, <w:tr> is a row node, and <w:tc> is a cell node. Mapping cell positioning information with underlying nodes can reduce the deviation of visual positioning, improve positioning accuracy, and only position the target node that needs to be edited without modifying other nodes, which can ensure the integrity of the overall structure of the template table file. For nested tables, merged cells across pages, etc., precise editing can also be achieved through node path positioning, which is suitable for table files with complex structures.

[0070] Next, according to the operation type, the content to be edited, and the format constraint, the cell editing operation is performed at the target node position to obtain a structured initial batch record table file. Based on the editing instruction parameters, the cell at the target node position can be edited. During the editing process, only the necessary nodes are modified, and the original format nodes of the template table file are preserved. For example, for text filling operations, the target node position is found <w:t>, if the node has the text content to be replaced, replace it with the corresponding text. If the node does not have the text content to be replaced, create a new node <w:t>node, ensuring that the cell format node is not modified <w:tcpr>and font format nodes <w:rpr>Each editing operation can record operation logs such as time stamp, target node identifier, operator, etc., for subsequent tracing. The edited nodes are recombined into a complete underlying structure file, which can form an initial record table file. In this way, the format of the template can be ensured not to be damaged.

[0071] The file in the reserved underlying structure format generated after editing is the initial record table file. The initial record table file does not undergo integrity checking, and the integrity checking is a multiple checking on file structure, content and compliance to ensure that the generated target batch record table file meets industry specifications and template requirements. Therefore, the initial batch record table file also needs to undergo integrity checking, and the initial batch record table file that passes the integrity checking is determined as the target batch record table file.

[0072] In one example, multi-dimensional integrity checking can be performed on the initial batch record table file. The integrity checking can include structure integrity checking, content integrity checking and compliance checking. The structure integrity checking is used to verify whether the structure of the initial record table file is consistent with the template table file. The content integrity checking is to verify whether the cell content of the initial record table file is complete, matches the semantic description, and the format is correct, etc. The compliance is to verify whether the data content meets the industry rules corresponding to the source document data.

[0073] The initial batch record table file that passes the integrity checking is written back from the underlying structure format to the editable format, and the compliance metadata is retained to generate the target batch record table file. The underlying structure format is the original format of the initial batch record table file, which is machine recognizable but difficult for manual editing. The editable format is a format that can be edited by humans. Repackaging the original underlying structure format into a standard editable format can facilitate subsequent manual review and editing.

[0074] The compliance metadata is additional information used to prove the compliance and integrity of the file, which can include generation time stamp, source document association number and checking hash value. The generation time stamp is the time when the initial batch record table file is generated, the source document association number is the unique identifier of the source document data in the initial batch record table file, and the checking hash value is a string generated based on the content of the initial batch record table file, which is used to verify whether the file is tampered.

[0075] The embodiments of the present application accurately locate the cells that need to be edited based on the editing behavior description, accurately perform editing operations based on the editing behavior description, and ensure the integrity and compliance of the data through complete row checking before generating the final target batch record table file. While ensuring the format, the content accuracy is also guaranteed, which improves the generation efficiency and compliance of the batch record table file.

[0076] Taking the pharmaceutical industry as an example, it is assumed that a production batch record table document of a drug needs to be generated as a target batch record table file, which involves that the document can include historical batch record files of other production lines, a batch record template Word table file and a source document of a production batch record, wherein the source document can include a production process procedure Word file and a supplier directory Word file. Figure 3 A flowchart of a batch record table generation method provided in an embodiment of the present application is shown in FIG. 1. Figure 3 As shown in the figure, the generation method includes steps 301-310.

[0077] Step 301, segmenting and slicing the historical batch record file by row and adding it to the vector database.

[0078] First, the batch record file XML is parsed and converted into an HTML format file, and the Hyper Text Markup Language (HTML) is segmented according to the table row using a large model prompt word (the table row contains various merged cells and nested cells). Then, the vectorization model is used for embedding vectorization, and the vectorized content is stored in the pgvector vector database. For example: the batch record table row is converted to "product name: glucose injection".

[0079] Step 302, import the template table file of the batch record, and perform OpenXML parsing to obtain an HTML format template table file.

[0080] Import the batch record template file to be generated (such as the "glucose injection batch production record" template from other production lines), which is in Word format and contains complex table structures (such as merged cells, nested tables, and cross-row parameter groups). Parse the document through OpenXML SDK to extract its table structure, style definition, and placeholder text, and generate a structured JSON representation. At the same time, the template is converted into an HTML format, retaining the table hierarchy and style information, which is used for subsequent multi-modal model understanding of the table space structure.

[0081] Step 303, slice the HTML format template table file by row to obtain multiple row template segment data, and extract the format attributes of the template segment data.

[0082] The HTML table parsed in step 302 is sliced by row according to the label to generate the smallest semantic unit. After cleaning (removing HTML tags and expanding merged cells), each row of text is input into an embedding model (such as text-embedding-ada-002 or a self-training domain model) to generate a 384-dimensional vector.

[0083] For example:

[0084] Input text:

[0085] Product name: Glucose Injection | Specification: 250ml:25g | Batch number: | Production date: ;

[0086] Output vector:

[0087] [0.112, -0.034, 0.225,..., 0.087];

[0088] All row vectors are written in bulk to the pgvector database, and a cosine similarity index is established to support efficient semantic retrieval.

[0089] Step 304, use RAG technology to retrieve the vector database, recall candidate table rows.

[0090] When the system receives a new batch of records to be generated, take a row in the template (such as "Sterilization parameters: temperature 121℃, time 30 minutes"), vectorize its text, and perform approximate nearest neighbor retrieval in the vector library to recall the top 10 similar historical row records. For example:

[0091] The search results are shown in Table 1.

[0092] Table 1

[0093]

[0094] These historical table rows serve as candidate contexts for the subsequent reasoning process.

[0095] Step 305, LLM performs semantic matching of candidate table rows with current row template segment data to obtain historical table rows.

[0096] Combine the current template row with the 10 historical rows recalled in step 4 to form prompt words, and input them into a large language model (such as GPT-4 or a domain fine-tuned model). The prompt is as follows:

[0097] You are an expert in pharmaceutical documents. Please select the "most semantically consistent" row from the following historical records, and explain the reason.

[0098]

Template row

[0099]

Candidate historical row

[0100] Final sterilization: 121℃, 30 minutes, verify FO ≥8. Please output the most matching row number and reason.

[0101] Model output:

[0102] Best match: Clause 2.

[0103] Reason: Both describe the "final sterilization" process, with identical temperature and time specifications, and include validation requirements, semantically equivalent.

[0104] This table row is selected as the "generate context" for guiding the subsequent content filling.

[0105] Step 306: Identify the cells of the multi-modal template fragment data through the visual language large model, and obtain the semantic description of the cells.

[0106] Convert the entire Word format template table file into a high-resolution Portable Document Format (PDF) image (300 dpi), and slice it by page. For each page image, combine the row-level text segmentation results in step 303 to construct multi-modal prompt words, input them into the visual-language large model (such as GPT-4V or LayoutLMv3), and perform table structure analysis and semantic annotation. For example:

[0107] Prompt words:

[0108] The following figure is a partial screenshot of the batch record template table. Please identify the table row (row 5) highlighted in the red box in the figure, and explain the meaning of each cell in the row, the type of content to fill in, and the key information points. For example: "Column 2 'Batch Number' should be filled in with a unique identifier for this batch, in the format 'YP + 6-digit year-month-day + 3-digit serial number'".

[0109] This analysis result is added as "table semantic annotation" to the prompt context, significantly improving the model's understanding of complex cells (such as "mix: add water for injection to the full amount of 90%, stir for 15 minutes") and reducing ambiguity generation.

[0110] Step 307: Analyze the source document data to determine the target text data for each row of template fragment data.

[0111] Analyze the source documents related to this production, including: "Glucose Injection Process Specification": extract key process parameters such as "preparation", "filling", and "sterilization"; "Supplier Directory of Raw Materials": extract "Glucose raw material supplier: XXX Company, batch number range: GLU240801-GLU241231"; "Quality Standards": extract "pH value range: 3.5~6.5", "content determination: should be 95.0%~105.0% of the labeled amount".

[0112] Convert these contents into structured text (such as Markdown or JSON), and label the source chapter number. Incorporate them into the prompt context uniformly, ensuring that the generated content is well-founded and meets the GMP and registration process requirements.

[0113] Step 308: Generate prompt words based on historical table rows, cell semantic descriptions, and target text data, input them into a large language model, and obtain the editing behavior description corresponding to each cell.

[0114] Integrate all the above contexts (historical similar rows + template structure + table semantic annotation + source document knowledge) to construct a complete prompt word, input it into a large model, and require it to output the "editing behavior" description of the template table. The structure of the prompt word can be as follows: You are a pharmaceutical document generation assistant. Please generate a "editing behavior" description for the batch record template table based on the following information. This "editing behavior" instruction set provides a precise operation path for subsequent structured rewriting.

[0115] Step 309: Perform XML-level editing on each cell based on the editing behavior description.

[0116] Combine the "editing behavior" instructions generated in step 308 with the original OpenXML template obtained in step 302 to construct a prompt word that guides the large model to locate and modify XML nodes. For example:

[0117] Prompt word:

[0118] Given the following OpenXML fragment (representing a row in a Word table), please modify the corresponding <w:t>The text content of the node is kept, and all styles and structures are kept unchanged. All editing operations are completed at the XML level, ensuring that the format, style, merged cells and other properties are completely retained, reducing the format disorder problem caused by text replacement in traditional solutions.

[0119] Step 310: Write the initial batch record table file with the edited XML structure back to a Word file, perform content rendering, and obtain the target batch record table file.

[0120] The edited OpenXML document structure is repackaged into a.docx file, and OpenXML SDK or python-docx library is called for serialization and writing back. The generated file contains: complete table structure (no broken merged cells); all placeholders are replaced with actual production data; key fields are accompanied by "source notes" (for example, the batch number "YP250905003" has a note "source: MES system batch number allocation record" in the upper right corner); the final output is "Glucose Injection Batch Production Record (Batch Number: YP250905003).docx"

[0121] It should be noted that the "historical data vectorization storage" in step 301 and the "template parsing" in step 302 can be completely parallel or interchanged. Steps 304 "RAG recall" and step 305 "large model fine arrangement" can be combined into one end-to-end retrieval-generation. "Historical batch records" are not limited to Word or HTML, but can also be PDF, scanned TIF, XLSX or MES system exported XML. In addition to process procedures and supplier directories, the following can also be introduced: real-time weighing data in electronic laboratory notebooks; Application Programming Interface (API) of Laboratory Information Management System (LIMS) test results; Internet of Things (IoT) time series data such as temperature and humidity, pressure - automatically associated and filled in "sterilization start / end temperature and humidity" column through "parameter name + time window"; drug regulatory audit opinions or historical defect lists, which are used to automatically avoid description errors that have occurred (such as "stirring to dissolve" being miswritten as "stirring to clarify") when generating.

[0122] Figure 4 A structure diagram of a batch record table generation device 400 provided in an embodiment of the present application. As shown in the structure diagram of the batch record table generation device 400, the batch record table generation device 400 can include a vector storage module 401, a structure analysis module 402, an instruction generation module 403, and a file editing module 404. Figure 4

[0123] ​The vector storage module 401 is configured to slice the historical table data of the historical batch record file by rows to obtain multi-row sample fragment data, extract the sample semantic vector of each row of sample fragment data, and store the sample semantic vector into a vector database.

[0124] The structure analysis module 402 is configured to slice the template table file by rows to obtain multi-row template fragment data, and extract the format attribute of each row of template fragment data.

[0125] The instruction generation module 403 is configured to construct guide information according to the vector database, the format attribute of the multi-row template fragment data, and the source document data, and generate an editing behavior description corresponding to each cell in the template table file based on the guide information, the guide information including a historical table row, a cell semantic description, and target text data of each row of template fragment data.

[0126] The file editing module 404 is configured to edit each cell in the template table file based on the editing behavior description to generate a target batch record table file.

[0127] The instruction generation module 403 can include a first prompting unit, a second prompting unit, a third prompting unit, and an integration unit.

[0128] The first prompting unit is configured to determine, based on the vector database, a historical table row having a semantic relationship with each row of template fragment data.

[0129] The second prompting unit is configured to determine, in combination with the format attribute of each row of template fragment data, a cell semantic description corresponding to each cell in each row of template fragment data.

[0130] The third prompting unit is configured to analyze source document data required for generating the target batch record table file, and determine, based on the source document data, target text data of each row of template fragment data.

[0131] The fourth prompting unit is configured to respectively integrate the historical table row, the cell semantic description, and the target text data of each row of template fragment data into a prompt word, input the prompt word into a large language model, and obtain an editing behavior description corresponding to each cell in each row of template fragment data.

[0132] The first prompting unit is further configured to extract text content of each row of template fragment data and convert the text content into a semantic text vector, calculate a similarity between the semantic text vector and a sample semantic vector in the vector database, select sample fragment data corresponding to a sample semantic vector having a similarity greater than a set similarity as a candidate table row, and perform semantic verification on a keyword of the candidate table row, and take a candidate table row passing the semantic verification as the historical table row.

[0133] The first prompting unit is further configured to convert the template table file into an image format and extract a visual format feature, construct a multi-modal prompt word in combination with a semantic text vector of each row of template segment data, input the multi-modal prompt word into a visual language large model, and obtain a format attribute of each cell in the template segment data and a corresponding cell semantic description.

[0134] The second prompting unit is further configured to parse a format attribute of each row of template segment data, extract a format feature, construct a semantic mapping rule based on the format feature, and generate a corresponding cell semantic description for each cell according to the semantic mapping rule.

[0135] The third prompting unit is further configured to perform structural analysis on source document data required for generating the target batch record table file, extract multi-type data, match a corresponding source document field label for each row of template segment data, retrieve the multi-type data based on the source document field label, filter candidate text data matched with the cell semantic description of each row of template segment data, and perform compliance verification on the candidate text data to determine target text data that passes the compliance verification.

[0136] The file editing module 404 can include an instruction extraction unit, a positioning unit, an initial generation unit, and a verification unit.

[0137] The instruction extraction unit is configured to perform structural analysis on the editing behavior description and extract editing instruction parameters, including cell positioning information, operation type, to-be-edited content, and format constraint.

[0138] The positioning unit is configured to determine a target node position corresponding to each cell positioning information based on the format attribute of the template segment data.

[0139] The initial generation unit is configured to perform a cell editing operation at the target node position according to the operation type, to-be-edited content, and format constraint, and obtain a structured initial batch record table file.

[0140] The verification unit is configured to perform integrity verification on the initial batch record table file, and determine the initial batch record table file that passes the integrity verification as a target batch record table file.

[0141] The verification unit is further configured to perform multi-dimensional integrity verification on the initial batch record table file, including structural integrity verification, content integrity verification, and compliance verification, rewrite the initial batch record table file in a bottom-layer structure format into an editable format while retaining compliance metadata, generate a target batch record table file, and the compliance metadata includes a generation timestamp, a source document association number, and a verification hash value.

[0142] Figure 5 A structure block diagram of a batch record form generation system 500 provided in an embodiment of the present application is shown. As shown, the batch record form generation system 500 can include a memory 501 and a processor 502. The memory 501 is configured to store instructions. The processor 502 is configured to call the instructions from the memory 501 and implement the batch record form generation method described above when the instructions are executed. Figure 5

[0143] An embodiment of the present application also provides a computer readable storage medium, which stores a program capable of being loaded by a processor and implementing the batch record form generation method of any of the embodiments of the present application.

[0144] Those skilled in the art can understand that all or part of the functions of the various methods in the above embodiments can be implemented in the form of hardware or in the form of a computer program. When all or part of the functions in the above embodiments are implemented in the form of a computer program, the program can be stored in a computer readable storage medium, which can include: read-only memory, random access memory, magnetic disk, optical disk, hard disk, etc. The above functions are implemented by executing the program by a computer. For example, the program is stored in the memory of a device, and when the program in the memory is executed by a processor, all or part of the above functions can be implemented. In addition, when all or part of the functions in the above embodiments are implemented in the form of a computer program, the program can also be stored in a server, another computer, a storage medium such as a disk, an optical disk, a flash disk or a mobile hard disk, and then downloaded or copied into the memory of a local device, or the system of the local device is updated, and when the program in the memory is executed by a processor, all or part of the functions in the above embodiments can be implemented.

[0145] The above application is described by using specific examples, which is only used to help understand the present application and does not limit the present application. Those skilled in the art can make some simple deductions, deformations or substitutions according to the idea of the present application.​< / w:t> < / w:rpr> < / w:tcpr> < / w:t> < / w:t> < / w:tbl>

Claims

1. A method of generating a batch record form, characterized by, The method comprises the following steps: slicing historical table data of a historical batch record file by rows to obtain multi-row sample segment data, and storing a sample semantic vector of each row of the sample segment data into a vector database; slicing a template table file by rows to obtain multi-row template segment data, and extracting a format attribute of each row of the template segment data; determining, based on the vector database, a historical table row having a semantic relationship with each row of the template segment data; determining, in combination with the format attribute of each row of the template segment data, a cell semantic description corresponding to each cell in each row of the template segment data; parsing source document data required for generating a target batch record table file, and determining, based on the source document data, target text data of each row of the template segment data; integrating the historical table row, the cell semantic description and the target text data of each row of the template segment data into a prompt word respectively, inputting the prompt word into a large language model, and obtaining an editing behavior description corresponding to each cell in each row of the template segment data; editing each cell in the template table file based on the editing behavior description to generate a target batch record table file; wherein the determination of the cell semantic description corresponding to each cell in each row of the template segment data in combination with the format attribute of each row of the template segment data comprises: parsing the format attribute of each row of the template segment data to extract a format feature, the format feature comprising cell merging information, font style marks and cell position coordinates; constructing a semantic mapping rule based on the format feature; generating a corresponding cell semantic description for each cell according to the semantic mapping rule.

2. The generation method of claim 1, wherein, The determination of the historical table row having a semantic relationship with each row of the template segment data based on the vector database comprises: extracting text content of each row of the template segment data and converting the text content into a semantic text vector; calculating a similarity between the semantic text vector and a sample semantic vector in the vector database; screening the sample segment data corresponding to the sample semantic vector with a similarity greater than a set similarity as a candidate table row; performing semantic verification of a keyword on the candidate table row, and taking the candidate table row passing the semantic verification as the historical table row.

3. The generation method of claim 2, wherein, The determination of the cell semantic description corresponding to each cell in each row of the template segment data in combination with the format attribute of each row of the template segment data comprises: converting the template table file into an image format and extracting a visual format feature, and constructing a multi-modal prompt word in combination with the semantic text vector of each row of the template segment data; inputting the multi-modal prompt word into a visual language large model to obtain the format attribute of each cell in the template segment data and the corresponding cell semantic description.

4. The generation method of claim 1, wherein, The parsing of source document data required for generating a target batch record table file, and the determination of target text data of each row of the template segment data based on the source document data comprise: Structural parsing of source document data required for generating a target batch record table file, extracting multi-type data including entity data, rule data and association data; Matching a corresponding source document field label for each row of the template fragment data; Retrieving the multi-type data based on the source document field label, and screening candidate text data matching the cell semantic description of each row of the template fragment data; Conducting compliance verification on the candidate text data, and determining the candidate text data passing the compliance verification as the target text data.

5. The generation method of claim 1, wherein, The editing based on the editing behavior description is performed on each cell in the template table file to generate a target batch record table file, including: Structural parsing of the editing behavior description to extract editing instruction parameters including cell positioning information, operation type, content to be edited and format constraints; Based on the format attribute of the template fragment data, determining the target node position corresponding to each cell positioning information; Performing a cell editing operation at the target node position according to the operation type, the content to be edited and the format constraints to obtain a structured initial batch record table file; Conducting integrity verification on the initial batch record table file, and determining the initial batch record table file passing the integrity verification as the target batch record table file.

6. The generation method of claim 5, wherein, The integrity verification on the initial batch record table file, and determining the initial batch record table file passing the integrity verification as the target batch record table file, includes: Performing multi-dimensional integrity verification on the initial batch record table file, including structural integrity verification, content integrity verification and compliance verification; Rewriting the initial batch record table file passing the integrity verification from the underlying structure format to an editable format while retaining compliance metadata including generation timestamp, source document association number and verification hash value, to generate the target batch record table file.

7. A batch record table generation device, characterized in that, It includes: A vector storage module for slicing historical table data of a historical batch record file by rows to obtain multi-row sample fragment data, and extracting a sample semantic vector of each row of the sample fragment data and storing it in a vector database; A structural analysis module for slicing a template table file by rows to obtain multi-row template fragment data, and extracting format attributes of each row of the template fragment data respectively; An instruction generation module including a first prompting unit, a second prompting unit, a third prompting unit and an integration unit; The first prompting unit is used to determine historical table rows having semantic relationships with each row of the template fragment data based on the vector database; The second prompting unit is used to determine a cell semantic description corresponding to each cell in each row of the template fragment data in combination with the format attribute of each row of the template fragment data; The third prompting unit is used to parse source document data required for generating a target batch record table file, and determine target text data of each row of the template fragment data based on the source document data; The integration unit is configured to integrate the history table row, the cell semantic description and the target text data of each row of the template fragment data into a prompt word respectively, input the prompt word into a large language model, and obtain an editing behavior description corresponding to each cell in each row of the template fragment data The file editing module is configured to edit each cell in the template table file based on the editing behavior description, and generate a target batch record table file. The second prompt unit is further configured to analyze a format attribute of each row of the template fragment data, extract a format feature, and construct a semantic mapping rule based on the format feature.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a program, and the program can be loaded and executed by the processor to perform the method of the batch record table generation method in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data analysis report generation method based on large language model

    CN118626523A

  • Table analysis method in pdf document suitable for RAG scene

    CN119691163A