A method and system for dividing contract documents

By identifying the characteristic elements of the contract document and building a paragraph dictionary, combined with the large language model and nested logic prompt word engineering, the segmentation mark is dynamically determined, solving the difficult splitting problem caused by the complexity of the contract document, and realizing intelligent and efficient document splitting. points effect.

CN118657122BActive Publication Date: 2024-10-29SHANGHAI ZHENLING TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411133429.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-10-29
Estimated Expiration
2044-08-19

AI Technical Summary

Technical Problem

Existing technology is difficult to effectively split complex contract documents, resulting in unsatisfactory automatic splitting results. Especially when the contract document has a flexible structure, diverse elements, and contains tables and pictures, a large amount of manual processing is required.

Method used

By identifying the characteristic elements of the contract document, a paragraph dictionary is constructed and sent to the large language model for processing. Combined with the nested logical prompt word project, the segmentation mark is dynamically determined to achieve intelligent splitting of the contract document.

Benefits of technology

It achieves intelligent, efficient and accurate splitting of contract documents, reduces manual intervention, retains the original document style, and can process documents containing pictures and tables.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657122B_ABST
    Figure CN118657122B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of document segmentation processing, and specifically to a contract document segmentation method and system. The present application solution identifies the first segmentation feature and the second segmentation feature of the contract document, and constructs a large language model configuration to determine the fuzzy segmentation mark, and then traverses the document, takes the elements that meet the segmentation feature as segmentation marks and sets segmentation points, and finally performs segmentation, which greatly reduces manual intervention while realizing automatic segmentation of contract documents and retains the original style; at the same time, the present application solution can also intelligently and effectively realize the segmentation of documents containing pictures and tables. Furthermore, the present application solution also greatly improves the accuracy of the large language model segmented contract documents by constructing a nested logic prompt word project.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of document segmentation processing, and specifically to a contract document segmentation method and system. Background Art

[0002] During contract processing, people often combine related (or sometimes even unrelated) documents into a single document for convenience. This is often the case with a main contract, annexes, and subsidiary agreements. Sometimes, annexes and subsidiary agreements may actually consist of multiple independent documents. In some cases, these independent documents may be missing or even completely devoid of content.

[0003] Merging documents is convenient in many ways, such as allowing them to be shared and copied as a whole to meet business system operational requirements. However, it can be detrimental to document use and processing. In any situation involving division of labor and collaboration, documents must be separated according to their structure and meaning, with each section assigned to the appropriate personnel. However, if this separation is not performed during document processing, whether using NLP or other techniques for extraction, matching, referencing, or optimization, the problem of one part of the contract document having a different or even conflicting meaning than another will arise, ultimately significantly reducing effectiveness.

[0004] Currently, mainstream document splitting tools automatically split documents by identifying page breaks or outlines, using them as split points. This approach only works for documents with accurate, comprehensive, and complete page breaks and outlines. Other attempts use NLP semantic understanding for splitting, but NLP technology itself requires comprehensive matching rules. Regardless of the approach, significant manual processing is required.

[0005] Furthermore, unlike general documents, contract documents are more complex. First, the structure of contract documents is extremely flexible. It can be very simple, such as just a few major clauses, or very complex, such as including a main contract, annexes, ancillary agreements, non-contractual documents, and cross-references. Second, the elements of contract documents are diverse and are not limited to simple text content. They can be composed of tables or images, either individually or in combination. Third, the status of contract documents is complex. Any contract document goes through a process from draft to finalization, and this process involves changes such as blank space, selection, repetition, and transfer. Therefore, due to the complexity and particularity of contract documents, existing splitting methods are not ideal for contract document segmentation. Summary of the Invention

[0006] Based on this, this application proposes a contract document segmentation method and system to address the above-mentioned problems, aiming to split contract documents intelligently, efficiently, accurately and dynamically to facilitate subsequent precise processing of the segmented contracts and improve system processing efficiency.

[0007] On one hand, the present application provides a method for segmenting a contract document, the method comprising:

[0008] Read and parse the contract documents to be processed;

[0009] Traversing the elements of the contract document to determine the first characteristic element and / or the second characteristic element in the contract document;

[0010] Adding the position of the first characteristic element and / or the starting position of the second characteristic element to a preset segmentation mark list;

[0011] Constructing the contract document paragraph dictionary;

[0012] Transmitting the paragraph dictionary data to a pre-configured large language model for processing to obtain fuzzy segmentation tags;

[0013] Adding the fuzzy segmentation mark to the segmentation mark list;

[0014] The contract document is divided into a plurality of sub-documents according to the segmentation mark list.

[0015] Preferably, the constructing of the contract document paragraph dictionary includes:

[0016] Number each paragraph of the contract document sequentially;

[0017] If the current paragraph is text, the paragraph number is used as the paragraph ID and the paragraph text is used as the paragraph content;

[0018] If the current paragraph contains embedded images and / or tables, the paragraph text and the object numbers of the embedded images and / or tables are used as the paragraph content;

[0019] If the current paragraph contains non-embedded images and / or tables, the non-embedded image and / or table object index is used as the paragraph ID, and the object index is used as the paragraph content;

[0020] Construct a paragraph dictionary, using the paragraph ID of the contract document as the dictionary key and the corresponding paragraph content as the dictionary value.

[0021] Furthermore, the method further comprises:

[0022] Select a preset large language model and configure its parameters;

[0023] Use the preset document structure and structural features as the knowledge base;

[0024] Constructing a preset nested logical prompt word project to fine-tune the large language model;

[0025] Inputting the paragraph dictionary data and the constructed prompt word engineering combination into the large language model;

[0026] Deserialize and / or verify the data returned by the large language model.

[0027] Preferably, the construction of the nested logic prompt word project includes:

[0028] Parse the dictionary data, use the dictionary value as the content, and retain the paragraph ID of the key value;

[0029] Determine whether the submitted content is the content of the contract document;

[0030] If so, determine the structure type in the knowledge base to which the structure of the contract document belongs;

[0031] Determine where the contract document can be considered a standalone contract based on the type of structure it belongs to;

[0032] If the dictionary data contains an image and / or table object, identifying the relevance of the image and / or table object to the content of the previous paragraph and / or the next paragraph, and determining the segmentation position based on the relevance;

[0033] The result is returned in a preset structure format, including the segmentation point paragraph ID and / or the corresponding text.

[0034] Preferably, the method further comprises:

[0035] Determine whether each marker in the segmentation marker list is located in the same paragraph;

[0036] If so, the paragraph content is extracted, input into the large language model for further processing, and the segmentation list marker is updated.

[0037] Preferably, segmenting the contract document according to the segmentation mark list includes:

[0038] Create a section list;

[0039] The starting position is the beginning position of the contract document;

[0040] Traverse the elements of the contract document from the starting position, and if the current element meets the characteristics of the segmentation mark list, use the current element as the target element;

[0041] Add the content from the starting position to the target element position as an object to the section list;

[0042] Traverse the rest of the document starting from the next element position of the target element until the entire document is traversed;

[0043] Iterate over the section list and copy the contents of each section object into a new document.

[0044] Furthermore, the method further comprises:

[0045] Determine the target type and associated target object of the segmented sub-document;

[0046] Establish a mapping relationship between each segmented sub-document and the associated target object.

[0047] A second aspect of the present application further provides a contract document segmentation system, the system comprising:

[0048] Document reading module, used to read and parse the contract documents to be processed;

[0049] a feature segmentation mark processing module, configured to traverse the elements of the contract document, determine a first feature element and / or a second feature element in the contract document, and add the location of the first feature element and / or the starting location of the second feature element to a preset segmentation mark list;

[0050] A dictionary building module, used to build the contract document paragraph dictionary;

[0051] a fuzzy segmentation mark processing module, configured to transmit the paragraph dictionary data to a pre-configured large language model for processing to obtain fuzzy segmentation marks; and to add the fuzzy segmentation marks to the segmentation mark list;

[0052] The document segmentation module is used to segment the contract document into multiple sub-documents according to the segmentation mark list.

[0053] In a third aspect, the present application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor executes the steps of any one of the above methods.

[0054] A fourth aspect of the present application provides a computer terminal device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the above methods.

[0055] The contract document segmentation solution provided in the present application identifies the first segmentation feature and the second segmentation feature of the contract document, constructs a large language model configuration to determine the fuzzy segmentation mark, and then traverses the document, uses the elements that meet the segmentation feature as segmentation marks and sets segmentation points, and finally performs segmentation. This greatly reduces manual intervention while achieving automatic segmentation of the contract document and retaining the original style. At the same time, the present application solution can also intelligently segment documents containing images and tables. Furthermore, the present application solution also greatly improves the accuracy of the large language model in segmenting the contract document by constructing a nested logical prompt word project. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0057] in:

[0058] Figure 1 A flowchart of the splitting and issuing of contract documents in one embodiment;

[0059] Figure 2 A structural block diagram of a contract document segmentation system in one embodiment;

[0060] Figure 3 FIG. 1 is a structural block diagram of a computer device in one embodiment. DETAILED DESCRIPTION

[0061] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0062] The terms "include", "comprising", and "having", and any variations thereof, in the specification and claims of this application and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products, or apparatuses. In the claims, specification, and accompanying drawings of this application, relational terms such as "first" and "second" are used only to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any actual relationship or order between these entities / operations / objects.

[0063] References to "embodiments" herein mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the present application. The appearance of the phrase at various locations in the specification does not necessarily refer to the same embodiment, nor are independent or alternative embodiments mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0064] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0065] In one embodiment, Figure 1 The flowchart of a contract document segmentation method of the present application is shown, and the method includes:

[0066] S10. Read and parse the contract document to be processed.

[0067] Specifically, the present application solution reads documents through a pre-defined interface or API and integrates different pre-defined mechanisms for parsing documents, depending on the document type (e.g., text file, PDF, Word document, etc.). Text files can be directly read and parsed; PDF or Word documents are parsed by integrating specialized libraries (e.g., Python's PyPDF2, pdfplumber, python-docx, etc.). Preferably, the present application solution is implemented for Word documents. For other types of documents, the present application also integrates corresponding document converters to convert other types of documents into Word documents before processing.

[0068] S11. Traverse the elements of the contract document to determine the first characteristic element and / or the second characteristic element in the contract document.

[0069] Preferably, in an example, the present application solution uses OpenXml to traverse each element in the document, identify the element type and content, and extract the necessary attributes of the current element for subsequent matching. The attributes may include content, style (such as font size, bold, italic), location information, etc. This identification process can be achieved by combining logical judgment with string comparison algorithms, regular expression matching, or other recognition algorithms.

[0070] During the traversal process, check whether each paragraph node element is a first characteristic element and / or a second characteristic element, where the first characteristic element is an element whose paragraph node type is a page break or section break, etc., and the second characteristic element includes: continuous line breaks (more than 2-3), "Heading1" style and other elements.

[0071] In one implementation, corresponding elements can be identified by combining regular expression matching. Alternatively, for Word documents, paragraph style information can be obtained using the python-docx library. The paragraphs list in the Document object contains all paragraphs in the document, and each paragraph object has a style attribute that represents the paragraph style. For PDF documents, paragraph elements can be inferred using corresponding parsing libraries based on features such as text position, font size, and bold.

[0072] S12: Add the location of the first characteristic element and / or the starting position of the second characteristic element to a preset segmentation mark list.

[0073] Specifically, in the present application, a segmentation marker list is pre-established for storing document segmentation point identifiers, and the structural format or field content of the segmentation marker list is defined as needed. During the traversal of the document, if the current element is a first characteristic element, the position of the current element is added to the segmentation marker list according to the format or field information of the segmentation marker list; if the current element is a second characteristic element, the starting position of the current element is added to the segmentation marker list according to the format or field information of the segmentation marker list.

[0074] S13. Construct the contract document paragraph dictionary.

[0075] Preferably, in one embodiment of the present application, a preset paragraph dictionary is defined, wherein the paragraph dictionary includes at least a key field and a value field for storing the paragraph ID and paragraph text of the document. After the dictionary is defined and created, a paragraph dictionary corresponding to the contract document is constructed based on the content of the contract document. Specifically, the construction of the contract document paragraph dictionary includes:

[0076] S131. Number each paragraph of the contract document in sequence.

[0077] S132. If the current paragraph is text, the paragraph number is used as the paragraph ID, and the paragraph text is used as the paragraph content.

[0078] S133. If the current paragraph contains an embedded image and / or table, the paragraph text and the object number of the embedded image and / or table are used as the paragraph content.

[0079] S134. If the current paragraph contains a non-embedded image and / or table, the object index number of the non-embedded image and / or table is used as the paragraph ID, and the object number index is used as the paragraph content.

[0080] S135. Construct a paragraph dictionary, using the paragraph ID of the contract document as the dictionary key and the corresponding paragraph content as the dictionary value.

[0081] The above scheme constructs paragraph dictionary data in a targeted manner according to the specific content of each paragraph in the document. In particular, for documents containing non-text objects such as pictures and / or tables, the object index ID corresponding to the pictures and / or tables is used as the paragraph content, so that when the large language model is subsequently submitted for processing, the specific pictures and / or table objects can be read as content according to the object index ID for processing.

[0082] S14: Transmit the paragraph dictionary data to a pre-configured large language model for processing to obtain fuzzy segmentation tags.

[0083] Specifically, this step mainly includes configuring and fine-tuning the large language model, transferring the dictionary data to the large language model for processing, and processing the results. Specifically, it includes:

[0084] S141: Select a preset large language model and configure parameters.

[0085] Specifically, we select an appropriate model architecture based on the task requirements and data characteristics, using a suitable pre-trained large language model as a foundation. This large language model should be one that has been pre-trained on a large amount of text, such as a deep learning model (CNN, RNN, Transformer, etc.), BERT, GPT, etc. These models have been trained on a large amount of text and possess rich language understanding capabilities.

[0086] After determining the model, set the model parameters according to actual needs, including but not limited to one or more of the following parameters: learning rate, batch size, number of iterations, network, number of layers, number of neurons, temperature and other parameters.

[0087] S142. Use the preset document structure and structural features as a knowledge base.

[0088] Preferably, the present application solution uses the preset document structure and structural features as a knowledge base to build an information storage system with a clear hierarchy and classification system. Such a knowledge base can help users quickly locate the required information and improve the efficiency and accuracy of information retrieval. Specifically, it includes:

[0089] Collect samples of various types of contract documents, identify various structural elements that should be recognized in the documents, such as titles, subtitles, body text, paragraphs, lists, tables, images, footers, and headers, and extract features from various parts of the documents, such as font style, size, color, position, spacing, alignment, etc.

[0090] Create a structured knowledge base to store the extracted features and structural information. The knowledge base can be a database, a file system, or a specific knowledge graph. Design a database schema or data structure to efficiently store and retrieve information from the knowledge base.

[0091] S143: Construct a preset nested logic prompt word project to fine-tune the large language model.

[0092] Prompt Engineering (or Prompt Tuning) is a method specifically designed to optimize language models. It aims to guide these models to produce more accurate and targeted output by designing and adjusting input prompts. When interacting with large pre-trained language models like GPT and BERT, the given prompts can significantly impact the content and quality of the model's responses. Therefore, for pre-trained language models, prompt engineering guides the model to produce high-quality, accurate, and targeted output by designing, experimenting with, and optimizing input prompts.

[0093] Preferably, in one embodiment of the present application, when designing prompt words, nested logic is used to guide the model to perform tasks in a specific order and nested structure. The nested logic involves multiple steps or subtasks, which are arranged in a certain order to form a complete solution.

[0094] Preferably, the nested logic prompt word construction project of the present application includes:

[0095] a. Parse the dictionary data, use the dictionary value as the content, and retain the paragraph ID of the key value.

[0096] b. Determine whether the submitted content is the content of the contract document: Based on the dictionary content information, determine whether the submitted content is the content of the contract document.

[0097] c. If so, determine the structure type in the knowledge base to which the structure of the contract document belongs based on the relevance; at the same time, it is necessary to eliminate the enthusiasm of the large prediction model and require that a null value be returned when there is no adapted answer.

[0098] d. Based on the structural type, determine where the contract document can be used as an independent contract. At the same time, it is necessary to eliminate the enthusiasm of the large prediction model and return a null value when no more likely segmentation features can be found under any structural type.

[0099] e. If the dictionary data contains an image and / or table object, identify the relevance of the image and / or table object with the content of the previous paragraph and / or the next paragraph, and determine the segmentation position based on the relevance.

[0100] f. Return the segmentation point paragraph ID and / or corresponding text in a preset structure format: The return result and return format are used as the restriction prompt word requirements, prompting the large model to intercept the corresponding text and ID as the return result, such as requiring the large prediction model to organize the data package into the format of {paragraph id: feature text}. When intercepting text, the following requirements must be met:

[0101] 1) The content must be captured without omission, including punctuation marks, spaces, special characters, and characters that may not be directly recognizable;

[0102] 2) The truncated length should ensure that this content is the only matching content in this paragraph.

[0103] According to the above nested logic prompt word project logic and steps, build the corresponding prompt word project.

[0104] This solution breaks down complex tasks into multiple subtasks by constructing a nested logic prompting system. Each subtask is then assigned a corresponding prompting term. These subtask prompts are arranged in a logically nested order. Furthermore, each subtask prompt includes clear instructions to guide the model through specific operations. This significantly improves the accuracy of large language models in determining contract document segmentation points.

[0105] Furthermore, in one embodiment, the present application also uses the prompt word project to fine-tune the large language model so that the large model learns how to respond to the constructed prompt word project and performs document segmentation based on the prompt word project. Specifically, it includes:

[0106] 1. Data preprocessing, including:

[0107] 1-1. Collect data: Collect datasets related to the document segmentation task. These datasets should contain rich text samples and corresponding segmentation labels.

[0108] 1-2. Data preprocessing: Perform preprocessing operations such as cleaning, word segmentation, and removal of stop words on the collected data.

[0109] 1-3. Label the dataset according to the requirements of the nested prompt words to ensure that each sample contains clear segmentation instructions.

[0110] 1-4. Divide the dataset: Divide the dataset into training set, validation set, and test set to facilitate model training and performance evaluation during fine-tuning.

[0111] 2. Fine-tune the large model, including:

[0112] 2-1. Select an appropriate fine-tuning method: Select an appropriate fine-tuning method based on model size, computing resources, and task complexity, such as full fine-tuning or efficient parameter fine-tuning (such as adapter tuning, prefix tuning, prompt tuning, etc.).

[0113] 2-2. Integrate nested cues: During fine-tuning, integrate the designed nested cues into the model. This can be achieved by modifying the model's default input layer or adding task-specific layers. For example, for large Transformer-based models, a special token can be added to the beginning of the input sequence to represent the cues, or additional attention mechanisms can be added within the model to focus on information related to the cues.

[0114] 2-3. Model training: Use the preprocessed training set to train the model so that the large model learns how to respond to the prompt words. During the training process, the model will learn how to more accurately segment documents based on the guidance of the nested prompt words, and monitor the model's performance on the validation set, adjusting training parameters or optimizing the model structure as needed. The specific process is as follows:

[0115] 2-3-1 Forward propagation: Pass the input data (including the prompt word) through the model to obtain the model prediction.

[0116] 2-3-2 Calculate loss: Use the loss function to compare the model prediction with the true label and calculate the loss value.

[0117] 2-3-3 Back propagation: Calculate the gradient through the back propagation algorithm based on the loss value.

[0118] 2-3-4 Parameter update: Update model parameters using gradient and optimization algorithms (such as Adam).

[0119] 2-3-5 Hyperparameter adjustment: During the training process, adjust hyperparameters such as learning rate and batch size to obtain the best training results.

[0120] 2-4. Evaluation and Optimization: Use the test set to evaluate the performance of the fine-tuned model. Based on the evaluation results, further optimize and adjust the model. If the model underperforms in certain areas, revisit and redesign the nested prompts or adjust the fine-tuning strategy. Furthermore, this application solution continuously monitors the model's performance in practice and continuously optimizes and adjusts the prompts based on user feedback and new data.

[0121] S144: Input the paragraph dictionary data and the constructed prompt word engineering combination into the large language model.

[0122] Preferably, in one embodiment of the present application, after constructing a nested logical prompt word project and training a large language model, the target text to be segmented and the constructed prompt words are combined into a complete input for the large language model for processing. For example, the prompt words are added as prefixes to the target text, or the target text and prompt words are embedded in the model's input sequence in a pre-set manner. Furthermore, if the value in the paragraph dictionary contains an image or table index, the corresponding image or table object is extracted based on the index and submitted to the model for recognition.

[0123] S145: Deserialize and / or verify the data returned by the large language model.

[0124] Specifically, to convert data from a serialized form (such as a string, byte stream, etc.) back to the original data structure or object, the present application solution deserializes the returned data packet. For JSON data, this can be performed using corresponding functions such as Python's json library, Java's Gson or Jackson, and C#'s Newtonsoft.Json. If the data returned by the large language model has already been deserialized, this step can be omitted. At the same time, because the returned data packet may not meet the verification requirements, the present application solution preprocesses the returned data packet. The preprocessing includes:

[0125] Use regular expressions to identify data and replace the text format in the data packet with the required format;

[0126] Use regular expressions to replace line breaks and various space codes in the text content of the data packet, such as \xa0, \n, and \r, with the space code of the target code.

[0127] S15: Add the fuzzy segmentation mark to the segmentation mark list.

[0128] Specifically, the deserialized and processed json format fuzzy segmentation mark data is appended to the segmentation mark list.

[0129] Preferably, in one embodiment, in order to further improve the accuracy of segmentation, the present application solution further verifies and processes each marker in the segmentation list, including:

[0130] Determine whether the tags in the segmentation list are in the same paragraph;

[0131] If so, the paragraph content is extracted, input into the large model for further processing, and the segmentation list marker is updated according to the result.

[0132] S16. Split the contract document into multiple sub-documents according to the segmentation mark list.

[0133] Preferably, segmenting the contract document according to the segmentation mark list includes:

[0134] S161. Create a section list.

[0135] Specifically, an empty section list is first created, to which section objects can be added.

[0136] S162. Take the beginning position of the contract document as the starting position.

[0137] S163. Traverse the contract document elements starting from the starting position. If the current element meets the characteristics of the segmentation mark list, use the current element as the target segmentation element.

[0138] S164: Add the content from the current starting position to the target segmentation element position as an object to the section list.

[0139] Specifically, the content from the current starting position to the current target segmentation element is added to the section list as a section object. This content can include text, elements, nodes, or any other form of document structure. When added to the section list, each list element contains the content of a complete or partial document, as well as possible other information (such as titles, styles, attributes, etc.). In this way, the list contains all the sections in the document, and each section exists as an independent object.

[0140] S165 , taking the position of the next element of the target segmentation element as the starting position, returning to S163 and looping through the remaining part of the document until the entire document is traversed.

[0141] S166: traverse the section list and copy the content of each section object into a newly created document.

[0142] Preferably, in one embodiment of the present application, each section object in the section list is traversed, and for each section object, a new sub-document is created, and the CloneNode method in OpenXml is used to copy all elements of the current object in the sections list to the newly created sub-document.

[0143] This solution constructs a section list to store the individual text segments, and combines it with the CloneNode method to ensure that the format of the new documents remains consistent with the original. Furthermore, when data is added to the section list, error checking and verification, as well as a deduplication mechanism, are performed to ensure that only correct data is copied to the new document, improving segmentation accuracy.

[0144] Furthermore, in one embodiment, the solution of the present application further includes performing the following verification and document processing on each segmented sub-document:

[0145] 1. Take each page as a unit and check whether there are blank pages in all split files. Delete the pages that meet the following characteristics and save them:

[0146] 1) Check whether the page contains text content;

[0147] 2) Check if the page contains only spaces;

[0148] 3) Check if the page contains only indents;

[0149] 4) Check if the page contains only page breaks;

[0150] 5) Check if the page contains only other preset empty content features.

[0151] 2. Add the first sentence of the segmentation mark text content or the first preset number of characters to a randomly generated 8-bit string as the file name of the segmented text.

[0152] 3. Save each split sub-file to the current directory or the specified directory.

[0153] The contract document segmentation solution provided in this application identifies the first and second segmentation features of the contract document and constructs a nested logic prompt word project combined with a large language model configuration to further determine the segmentation markers of the contract document. It then traverses the document, identifies elements that meet the segmentation features as segmentation markers, sets segmentation points, and finally performs segmentation. This greatly reduces manual intervention while achieving automatic segmentation of the contract document and retaining the original style. Furthermore, this application solution can also intelligently segment documents containing images and tables.

[0154] Furthermore, the method further comprises:

[0155] S17: Determine the target type and associated target object to which the segmented sub-document belongs.

[0156] Specifically, the present application solution identifies each sub-document by naming it or extracting preset subject information, and then determines the business target type of each segmented sub-document based on the authority and scope of each business type in the organizational structure through similarity calculation or matching algorithm. For example, the sub-document involving "financial terms" is determined to be a financial target type, and the sub-document involving "legal terms" is determined to be a legal target type, etc.

[0157] Furthermore, the department or personnel target objects associated with each sub-document are determined based on the responsibilities and requirements of each business department and personnel allocation in the organizational structure, as well as the target type of each segmented sub-document. This can be determined based on the content, type, priority, pre-set association information, etc. of the sub-document.

[0158] S18: Establish a mapping relationship between each segmented sub-document and the associated target object.

[0159] Preferably, in one embodiment, the present application solution uses a preset document management system to establish a mapping relationship. Create and import department or personnel information or accounts in the system, set corresponding permissions and folder structures, and map sub-documents to corresponding department or personnel accounts through the interface or API of the document management system. During the mapping process, access permissions, modification permissions, etc. can be set to ensure data security. Permission control includes: setting different permission levels for different departments or personnel according to actual needs. For example, some departments or personnel may only need to view the document content without modification; while other departments or personnel may require full access and modification permissions.

[0160] After establishing the mapping relationship, this application solution will send each sub-document and its requirements to the corresponding target account for processing based on business needs. The application will also notify the relevant personnel via email, instant messaging, or other means which sub-documents they have been assigned to review or modify. The notification will provide the access link or path to the sub-document, as well as the deadline and any special requirements.

[0161] At the same time, this application introduces a version control mechanism during the review and modification process: During the review and modification process, a version control strategy is implemented to ensure that the version of each sub-document is clear and traceable, and each modification should record information such as the modifier, modification time, and modification content.

[0162] In one embodiment, Figure 2 FIG2 shows a contract document segmentation system provided by the second aspect of the present application, the system comprising:

[0163] Document reading module, used to read and parse the contract documents to be processed;

[0164] a feature segmentation mark processing module, configured to traverse the elements of the contract document, determine a first feature element and / or a second feature element in the contract document, and add the location of the first feature element and / or the starting location of the second feature element to a preset segmentation mark list;

[0165] A dictionary building module, used to build the contract document paragraph dictionary;

[0166] A fuzzy segmentation mark processing module is used to transmit the paragraph dictionary data to a pre-configured large language model for processing to obtain a fuzzy segmentation mark; and add the fuzzy segmentation mark to the segmentation mark list;

[0167] The document segmentation module is used to segment the contract document into multiple sub-documents according to the segmentation mark list.

[0168] In one embodiment, the present application further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor performs the following steps:

[0169] Read and parse the contract documents to be processed;

[0170] Traversing the elements of the contract document to determine the first characteristic element and / or the second characteristic element in the contract document;

[0171] Adding the position of the first characteristic element and / or the starting position of the second characteristic element to a preset segmentation mark list;

[0172] Constructing the contract document paragraph dictionary;

[0173] The paragraph dictionary data is sent to a pre-configured large language model for processing to obtain fuzzy segmentation tags;

[0174] Adding the fuzzy segmentation mark to the segmentation mark list;

[0175] The contract document is divided into a plurality of sub-documents according to the segmentation mark list.

[0176] In one embodiment, Figure 3 The present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following steps:

[0177] Read and parse the contract documents to be processed;

[0178] Traversing the elements of the contract document to determine the first characteristic element and / or the second characteristic element in the contract document;

[0179] Adding the position of the first characteristic element and / or the starting position of the second characteristic element to a preset segmentation mark list;

[0180] Constructing the contract document paragraph dictionary;

[0181] The paragraph dictionary data is sent to a pre-configured large language model for processing to obtain fuzzy segmentation tags;

[0182] Adding the fuzzy segmentation mark to the segmentation mark list;

[0183] The contract document is divided into a plurality of sub-documents according to the segmentation mark list.

[0184] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0185] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0186] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be determined by the appended claims.

Claims

1. A contract document segmentation method, It is characterized in that The method comprises: Read and parse the contract documents to be processed; Traversing the elements of the contract document to determine the first characteristic element and / or the second characteristic element in the contract document; Adding the position of the first characteristic element and / or the starting position of the second characteristic element to a preset segmentation mark list; Constructing the contract document paragraph dictionary; The paragraph dictionary data is sent to a pre-configured large language model for processing to obtain fuzzy segmentation tags; Adding the fuzzy segmentation mark to the segmentation mark list; The contract document is divided into a plurality of sub-documents according to the segmentation mark list.

2. The method according to claim 1, It is characterized in that The step of constructing the contract document paragraph dictionary includes: Number each paragraph of the contract document in sequence; If the current paragraph is text, the paragraph number is used as the paragraph ID, and the paragraph text is used as the paragraph content; If the current paragraph contains embedded images and / or tables, the paragraph text and the object numbers of the embedded images and / or tables are used as the paragraph content; If the current paragraph contains non-embedded images and / or tables, the non-embedded image and / or table object index is used as the paragraph ID, and the object index is used as the paragraph content; Construct a paragraph dictionary, using the paragraph ID of the contract document as the dictionary key and the corresponding paragraph content as the dictionary value.

3. The method according to claim 2, It is characterized in that The method further comprises: Select a preset large language model and configure its parameters; Using the preset document structure and structural features as the knowledge base; Constructing a preset nested logic prompt word project and adjusting the large language model; Inputting the paragraph dictionary data and the constructed prompt word engineering combination into the large language model; Deserialize and / or verify the data returned by the large language model.

4. The method according to claim 3, It is characterized in that The nested logic prompt word construction project includes: Parse the dictionary data, use the dictionary value as the content, and retain the paragraph ID of the key value; Determine whether the submitted content is the content of the contract document; If so, determining the structure type in the knowledge base to which the structure of the contract document belongs; Determine where the contract document can be considered a stand-alone contract based on the type of structure it is in; If the dictionary data contains an image and / or table object, identifying the relevance of the image and / or table object to the content of the previous paragraph and / or the next paragraph, and determining the segmentation position based on the relevance; The result is returned in a preset structure format, including the segmentation point paragraph ID and / or the corresponding text.

5. The method according to claim 1, It is characterized in that The method further comprises: Determine whether each marker in the segmentation marker list is located in the same paragraph; If so, the content of the paragraph is extracted, input into the large language model for further processing and the segmentation marker list is updated.

6. The method according to claim 1, It is characterized in that The step of segmenting the contract document according to the segmentation mark list includes: Create a section list; Taking the beginning position of the contract document as the starting position; Traverse the elements of the contract document from the starting position, and if the current element meets the characteristics of the segmentation mark list, take the current element as the target element; Add the content from the starting position to the target element position as an object to the section list; Traverse the rest of the document starting from the position of the next element of the target element until the entire document is traversed; Iterate over the section list, copying the contents of each section object into a newly created document.

7. The method according to any one of claims 1 to 6, It is characterized in that The method further comprises: Determine the target type and associated target object to which the segmented sub-document belongs; Establish a mapping relationship between each segmented sub-document and the associated target object.

8. A contract document segmentation system, It is characterized in that The system comprises: Document reading module, used to read and parse the contract documents to be processed; A feature segmentation mark processing module, used to traverse the elements of the contract document, determine the first feature element and / or the second feature element in the contract document; and add the location of the first feature element and / or the starting position of the second feature element to a preset segmentation mark list; A dictionary building module, used to build the contract document paragraph dictionary; A fuzzy segmentation mark processing module is used to transmit the paragraph dictionary data to a pre-configured large language model for processing to obtain a fuzzy segmentation mark; and add the fuzzy segmentation mark to the segmentation mark list; The document segmentation module is used to segment the contract document into multiple sub-documents according to the segmentation mark list.

9. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 7.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Document segmentation method and device and electronic equipment

    CN111832258A

  • PDF document paragraph presentation method and device, storage medium and equipment

    CN113378525A