Contract document segmentation method and system

By identifying the characteristic elements of the contract document and constructing a paragraph dictionary, combined with the large language model and the nested logic prompt word project, the intelligent splitting of the contract document is realized, which solves the problem of unsatisfactory splitting effect in the existing technology and reduces the labor cost. intervened and improved accuracy.

CN118657122AActive Publication Date: 2024-09-17SHANGHAI ZHENLING TECH CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202411133429.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-09-17
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 and requiring a lot of manual processing, especially when the contract document has a flexible structure, diverse elements and complex status.

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, and fuzzy segmentation tags are generated. Combined with the nested logic prompt word engineering fine-tuning model, the contract document can be split intelligently and efficiently.

Benefits of technology

It realizes the automatic splitting of contract documents, reduces manual intervention, retains the original document style, and improves the accuracy of splitting documents containing pictures and tables.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657122A
    Figure CN118657122A
Patent Text Reader

Abstract

The invention relates to the technical field of document segmentation processing, in particular to a contract document segmentation method and system. According to the scheme, the first segmentation feature and the second segmentation feature of the contract document are recognized, the large language model is constructed to configure and determine the fuzzy segmentation mark, then the document is traversed, the elements conforming to the segmentation features serve as the segmentation marks, the segmentation points are set, and finally segmentation is conducted. Manual intervention is greatly reduced, meanwhile, automatic splitting of the contract document is achieved, and the original style is reserved; meanwhile, according to the scheme, the document containing the pictures and the tables can be intelligently and effectively split. Furthermore, according to the scheme of the invention, by constructing a nested logic cue word project, the accuracy of segmenting the document of the contract by the large language model is greatly improved.
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 in particular to a contract document segmentation method and system. Background Art

[0002] In the process of contract business processing, people often combine related (sometimes even unrelated) documents into one document for convenience, such as the main contract, annexes, and subsidiary agreements. Sometimes annexes and subsidiary agreements may actually consist of multiple relatively independent documents. In some special cases, the content of these relatively independent documents is missing or even does not contain any content.

[0003] Merging documents is convenient in many aspects, such as providing or copying them to others as a whole to meet the requirements of business system operations, but it is not conducive to the use and processing of documents. In any situation where there is division of labor and cooperation, documents must be split according to their structure and meaning so that each part of the document can be handed over to the corresponding personnel; and when processing documents, if they are not split, whether NLP technology or other technologies are used for extraction, matching, quoting, and optimization, there will be problems such as one part of the contract document having different or even conflicting meanings with other parts, which will ultimately greatly reduce the effect.

[0004] The current mainstream document splitting tools realize automatic splitting by identifying page breaks or outlines and using them as splitting points. This method can only process documents with page breaks and outlines, and the page breaks and outlines are accurate, comprehensive, and complete. There are also attempts to use NLP semantic understanding for splitting, but NLP technology itself requires all matching rules. Regardless of the method used, a lot of manual processing is required.

[0005] Furthermore, unlike general documents, contract documents are more complex, as shown in the following aspects: first, the structure of contract documents is extremely flexible. It can be very simple, such as only a few main clauses, or very complex, such as including the main contract, annexes, subsidiary agreements, non-contract documents and cross-references; second, the elements of contract documents are diverse, not limited to simple text content, but can be composed of tables or pictures alone or together; third, the status of contract documents is complex. Any contract document is a process from draft to finalization, and there are changes in the process such as blank space, selection, repetition, and transfer. Therefore, based on the complexity and particularity of contract documents, the existing splitting processing method is not ideal for the contract document segmentation effect. 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, so as to facilitate the subsequent precise processing of the segmented contracts and improve the system processing efficiency.

[0007] On one hand, the present application provides a method for segmenting a contract document, the method comprising: 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; Transmitting the paragraph dictionary data to a pre-configured large language model for processing to obtain fuzzy segmentation marks; 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.

[0008] Preferably, the constructing of 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.

[0009] Furthermore, 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 to fine-tune 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.

[0010] Preferably, the construction of the nested logic prompt word 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.

[0011] Preferably, the method further comprises: Determine whether each marker in the segmentation marker list is located in the same paragraph; If so, the paragraph content is extracted, input into the large language model for further processing and the segmentation list marker is updated.

[0012] Preferably, 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.

[0013] Furthermore, 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.

[0014] The second aspect of the present application also provides a contract document segmentation system, the system comprising: 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, used for transmitting the paragraph dictionary data to a pre-configured large language model for processing to obtain a fuzzy segmentation mark; and adding 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.

[0015] The third aspect of the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to perform the steps of any one of the above methods.

[0016] 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.

[0017] The contract document segmentation solution provided in the present application 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 realize the segmentation of documents containing pictures and tables. Furthermore, the present application solution also greatly improves the accuracy of the large language model segmentation of the contract document by constructing a nested logic prompt word project. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 creative work.

[0019] in: Figure 1 A flowchart of contract document segmentation and distribution in one embodiment; Figure 2 A structural block diagram of a contract document segmentation system in one embodiment; Figure 3 FIG. 4 is a structural block diagram of a computer device in one embodiment. DETAILED DESCRIPTION

[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0021] The terms "include", "comprising" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device 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 devices. In the claims, specification and drawings of the present application, relational terms such as "first" and "second" are merely used to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any such actual relationship or order between these entities / operations / objects.

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

[0023] 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.

[0024] In one embodiment, if Figure 1 The flowchart of a method for segmenting a contract document of the present application is shown, and the method comprises: S10. Read and parse the contract document to be processed.

[0025] Specifically, the solution of the present application reads documents through a preset interface or API, and integrates different preset mechanisms to parse documents, depending on the type of document (such as text files, PDFs, Word documents, etc.). For text files, they can be read and parsed directly; for PDF or Word documents, they are parsed by integrating and using specialized libraries (such as Python's PyPDF2, pdfplumber, python-docx, etc.). Preferably, the solution of the present application is implemented for word documents, and for other types of documents, the present application integrates corresponding document converters to convert other types of documents into word documents before implementing the processing.

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

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

[0028] 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.

[0029] In one embodiment, the corresponding element can be identified by combining regular expression matching, or for Word documents, the style information of the paragraph can be obtained through the python-docx library. The paragraphs list in the Document object contains all the paragraphs in the document, and each paragraph object has a style attribute that indicates the style of the paragraph. For PDF documents, the paragraph element can be inferred based on text position, font size, bold, and other features through the corresponding parsing library.

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

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

[0032] S13, constructing the contract document paragraph dictionary.

[0033] Preferably, in one embodiment of the present application, a preset paragraph dictionary is defined, the paragraph dictionary at least includes a key field and a value field, which are used to store the paragraph ID and paragraph text of the document. After the dictionary is defined and created, the paragraph dictionary corresponding to the contract document is constructed according to the content of the contract document. Specifically, the construction of the contract document paragraph dictionary includes: S131. Number each paragraph of the contract document in sequence.

[0034] 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.

[0035] 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.

[0036] S134. If the current paragraph contains non-embedded images and / or tables, the non-embedded images and / or table object index number is used as the paragraph ID, and the object number index is used as the paragraph content.

[0037] 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.

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

[0039] S14, transmitting the paragraph dictionary data to a pre-configured large language model for processing to obtain fuzzy segmentation marks.

[0040] Specifically, this step mainly includes configuring and fine-tuning the large language model and transmitting the dictionary data to the large language model for processing and processing the results. Specifically includes: S141. Select a preset large language model and configure parameters.

[0041] Specifically, select a suitable model architecture based on task requirements and data characteristics, and select a suitable pre-trained large language model as the basis. The selected large language model is a model 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 have rich language understanding capabilities.

[0042] 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.

[0043] S142. Using the preset document structure and structural features as a knowledge base.

[0044] Preferably, the present application scheme uses the preset document structure and structural features as the 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 including: Collect samples of various types of contract documents, determine the various structural elements that should be identified in the document, such as title, subtitle, body, paragraphs, lists, tables, pictures, footers and headers, etc., and extract features from various parts of the document, such as font style, size, color, position, spacing, alignment, etc.

[0045] 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 in the knowledge base.

[0046] S143, constructing a preset nested logic prompt word project to fine-tune the large language model.

[0047] Prompt Engineering (or Prompt Tuning) is a method specifically designed for optimizing language models. It aims to guide these models to generate more accurate and targeted output results by designing and adjusting the input prompts. When interacting with large pre-trained language models such as GPT, BERT, etc., the given prompts will greatly affect the content and quality of the model's response. Therefore, for pre-trained language models, prompt engineering guides the model to generate high-quality, accurate and targeted outputs by designing, experimenting and optimizing the input prompts.

[0048] 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, and the nested logic involves multiple steps or subtasks, which are arranged in a certain order to form a complete solution.

[0049] Preferably, the nested logic prompt word construction project of the present application includes: a. Parse the dictionary data, use the dictionary value as the content, and retain the paragraph ID of the key value.

[0050] 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.

[0051] 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 suitable answer.

[0052] d. Based on the structural type, determine the position of the contract document that 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.

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

[0054] f. Return the segmentation point paragraph ID and / or corresponding text in a preset structure format: Use the return result and return format 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 it into a data packet in the format of {paragraph id: feature text}. When intercepting text, the following requirements must be met: 1) The content must be captured without omission, including punctuation marks, spaces, other special characters, and characters that may not be directly recognizable; 2) The length of the truncation should ensure that this content is the only matching content in this paragraph.

[0055] According to the above nested logic prompt word project logic and steps, build the corresponding prompt word project. The above solution of the present application decomposes complex tasks into multiple subtasks by constructing a nested logic prompt word project, and designs corresponding prompt words for each subtask. The prompt words of these subtasks need to be arranged in the order of execution to form a logical nested relationship. At the same time, in the prompt words of each subtask, clear instructions are used to guide the model to perform specific operations. In this way, the accuracy of the large language model in determining the segmentation points of the contract document is greatly improved.

[0056] 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 according to the prompt word project. Specifically, it includes: 1. Data preprocessing, including: 1-1. Collect data: Collect datasets related to the document segmentation task. These datasets should contain rich text samples and corresponding segmentation labels.

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

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

[0059] 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.

[0060] 2. Fine-tune the large model, including: 2-1. Choose an appropriate fine-tuning method: Choose an appropriate fine-tuning method based on the 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.).

[0061] 2-2. Integrate nested prompts: During fine-tuning, integrate the designed nested prompts into the model, which can be achieved by modifying the model's preset input layer or adding specific task-specific layers. For example, for a large Transformer-based model, you can add a special token at the beginning of the input sequence to represent the prompt, or add an additional attention mechanism inside the model to focus on information related to the prompt.

[0062] 2-3. Model training: Use the preprocessed training set to train the model so that the large model learns how to respond to prompt words. During the training process, the model will learn how to segment documents more accurately based on the guidance of the nested prompt words, and monitor the performance of the model on the validation set, and adjust the training parameters or optimize the model structure as needed. The specific process is as follows: 2-3-1 Forward propagation: Pass the input data (including the prompt word) through the model to obtain the model prediction.

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

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

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

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

[0067] 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 it is found that the model performs poorly in some aspects, you can go back and redesign the nested prompt words or adjust the fine-tuning strategy. In addition, the application solution also continuously monitors the performance of the model in actual applications, and continuously optimizes the model and adjusts the prompt words based on user feedback and new data.

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

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

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

[0071] Specifically, in order 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, you can use Python's json library, Java's Gson or Jackson, C#'s Newtonsoft.Json and other corresponding functions to execute. If the data returned by the large language model has been deserialized, this step can be omitted. At the same time, since the returned data packet may not meet the verification requirements, the present application solution preprocesses the returned data packet, and the preprocessing includes: Use regular expressions to identify data and replace the text format in the data packet with the required format; Use regular expressions to replace the 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.

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

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

[0074] Preferably, in one embodiment, in order to further improve the accuracy of segmentation, the present application solution further verifies and processes each mark in the segmentation list, including: Determine whether the tags in the segmentation list are in the same paragraph; If so, extract the paragraph content, input it into the large model for further processing and update the segmentation list mark according to the result.

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

[0076] Preferably, segmenting the contract document according to the segmentation mark list includes: S161. Create a section list.

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

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

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

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

[0081] Specifically, the content from the current starting position to the current target segmentation element position is added to the section list as a section object, including text, elements, nodes or any other document structure. When added to the section list, each list element content contains the content of a complete or partial document, as well as possible other information (such as title, style, attributes, etc.). In this way, the list contains all the parts in the document, and each part exists as an independent object.

[0082] S165. Take the position of the next element of the target segmentation element as the starting position, return to S163 and loop through the remaining part of the document until the entire document is traversed.

[0083] S166. Traverse the section list and copy the content of each section object to a newly created document.

[0084] 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.

[0085] The above solution of the present application constructs a section list to segment and store each segmented text content, and combines the CloneNode method to ensure that the format of the segmented new document is consistent with the original document. In addition, when the data content is added to the section list, error checking and verification can be performed and a deduplication mechanism can be introduced to ensure that only correct data is copied to the new document, thereby improving the accuracy of segmentation.

[0086] Furthermore, in one embodiment, the solution of the present application further includes performing the following inspection and document processing on each segmented sub-document: 1. Take each page as a unit, check whether there are blank pages in all split files, and delete the pages that meet the following characteristics and save them: 1) Check whether the page contains text content; 2) Check if the page contains only spaces; 3) Check if the page contains only indents; 4) Check if the page contains only page breaks; 5) Check if the page contains only other preset empty content features.

[0087] 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.

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

[0089] The contract document segmentation solution provided in the present application further determines the segmentation mark of the contract document by identifying the first segmentation feature and the second segmentation feature of the contract document, and constructing a nested logic prompt word project combined with a large language model configuration. Then the document is traversed, and the elements that meet the segmentation features are used as segmentation marks and segmentation points are set, and finally segmentation is performed, which greatly reduces manual intervention while realizing automatic segmentation of the contract document and retaining the original style; further, the present application solution can also intelligently realize the segmentation of documents containing pictures and tables.

[0090] Furthermore, the method further comprises: S17: Determine the target type and associated target object to which the segmented sub-document belongs.

[0091] Specifically, the present application scheme 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, a sub-document involving "financial terms" is determined to be a financial target type, and a sub-document involving "legal terms" is determined to be a legal target type, etc.

[0092] Furthermore, the sub-documents and the associated department or personnel target objects are determined based on the responsibilities and requirements of each business department and personnel allocation in the organizational structure, and 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-documents.

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

[0094] Preferably, in one embodiment, the present application scheme 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 need full access and modification permissions.

[0095] After the mapping relationship is established, this application solution sends each sub-document and requirement to the corresponding target account for corresponding business processing according to business needs. And notify the relevant personnel by email, instant messaging tools or other means which sub-documents they have been assigned for review or modification, provide the access link or path of the sub-document in the notification, and explain the deadline and any special requirements.

[0096] 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.

[0097] In one embodiment, Figure 2 A contract document segmentation system provided in the second aspect of the present application is shown, and the system includes: 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.

[0098] In one embodiment, the present application further provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor performs the following steps: 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.

[0099] In one embodiment, Figure 3 The present application also 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: 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.

[0100] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and 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 may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many 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).

[0101] The technical features of the above embodiments may be arbitrarily combined. 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.

[0102] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A contract document segmentation method, 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, 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, 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, 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, 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 paragraph content 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, 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, 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, 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 detecting method and document detecting device

    CN102915295A

  • Document segmentation method and device and electronic equipment

    CN111832258A

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

    CN113378525A

  • Article outline generation method and device and storage medium

    CN117633214A

  • Document segmentation method and system based on large language model auxiliary title extraction

    CN118072339A