A contract archive resource automatic intelligent classification identification method, system, device and medium
By constructing a knowledge graph of the contract domain and a pre-trained language model, combined with graph attention networks and multi-label classifiers, the problem of low classification accuracy of medical contract files in traditional methods is solved, and high-precision and stable automated management is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUXIN CENT HOSPITAL
- Filing Date
- 2026-02-25
- Publication Date
- 2026-06-02
Smart Images

Figure CN122132566A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of contract file classification technology, and in particular relates to an automatic intelligent classification and identification method, system, device and medium for contract file resources. Background Technology
[0002] With the deepening of information technology construction in medical institutions, contract files, as important legal documents recording hospital operations, procurement, cooperation, and scientific research activities, are increasingly being managed digitally and intelligently. Traditional contract file management methods are gradually being supplemented by automated technologies based on optical character recognition (OCR) and natural language processing (NLP) to achieve rapid input and preliminary organization of file content.
[0003] In traditional technologies, the classification of electronic contract files often relies on pre-defined keyword matching rules or machine learning models based on general text features. Specifically, administrators need to manually define a series of keywords related to contract types, and the system categorizes them by scanning document content; or a classification model can be trained using a batch of labeled contract samples to predict the category of new contracts based on the statistical features of the text.
[0004] However, current automated or traditional methods have significant technical problems. Due to the highly specialized and standardized nature of medical contract texts, which contain numerous specific legal terms, medical jargon, and complex clause structures, general keyword matching methods struggle to handle polysemy, contextual semantic relationships, and newly emerging terms, resulting in low classification accuracy and poor recall. Furthermore, machine learning models trained on general corpora lack a deep understanding of the medical contract domain and cannot effectively capture the inherent logical connections between contract types, specific clause content, and text structure. When faced with diverse and complex real-world hospital contracts, their classification performance is unstable, and the models have poor interpretability, failing to meet hospitals' actual needs for high-precision, high-efficiency, and intelligent management of contract files. Summary of the Invention
[0005] Therefore, it is necessary to provide a method, system, device, and medium for automatic intelligent classification and identification of contract archive resources to address the aforementioned technical problems.
[0006] Firstly, this application provides an automatic intelligent classification and identification method for contract archive resources, including:
[0007] S1. Based on historical contract archives and publicly available legal provisions, a contract domain knowledge graph is constructed through domain entity extraction and relationship mining; the contract domain knowledge graph includes legal concepts, business terms, and contract type entities;
[0008] S2. Perform format parsing and text extraction on the contract archive documents to be classified to obtain the original text sequence, and then clean and segment the original text sequence to obtain the segmented word sequence.
[0009] S3. Input the word sequence into the pre-trained language model to obtain the context semantic vector sequence;
[0010] S4. Link the context semantic vector sequence and the contract domain knowledge graph to obtain the linking result, and aggregate the multi-hop neighbor information of relevant entities in the contract domain knowledge graph based on the linking result to generate a knowledge-enhanced text feature vector sequence.
[0011] S5. Extract structural features from the chapters of the contract archive document to obtain the document structure vector;
[0012] S6. Aggregate the knowledge-enhanced text feature vector sequence and combine it with the document structure vector. Calculate the probability that the contract archive document belongs to each preset category label using a multi-label classifier to obtain the classification result.
[0013] In one embodiment, based on historical contract archives and publicly available legal provisions, a contract domain knowledge graph is constructed through domain entity extraction and relationship mining, including:
[0014] S11. Segment and sentence-level segmentation of historical contract archives and publicly available legal provisions to obtain a set of text units;
[0015] S12. Based on a predefined entity type dictionary and rules, extract legal concept entities and business term entities from the text unit set;
[0016] S13. Based on the titles, summaries, and key clauses of historical contract archives, identify and define contract type entities using clustering algorithms;
[0017] S14. Based on legal concept entities, business term entities, and contract type entities, use a relational classification model to mine the relationships between entities and form a set of relational triples.
[0018] S15. Import the legal concept entities, business term entities, contract type entities, and relation triples into the graph database to construct a knowledge graph for the contract domain.
[0019] In one embodiment, the contract documents to be classified are parsed and their text extracted to obtain an original text sequence. This original text sequence is then cleaned and segmented to obtain a segmented word sequence, including:
[0020] S21. Based on the file extension of the contract file, call the corresponding document parser to parse the format of the contract file and obtain the parsed document.
[0021] S22. Perform layout analysis on the document after format parsing, distinguish between text areas and non-text areas, extract character content from all text areas, and concatenate them to obtain the original text sequence.
[0022] S23. Clean the original text sequence to remove illegal characters, redundant spaces and format marks, and obtain a regular text sequence.
[0023] S24. Perform word segmentation on the regular text sequence to obtain the initial word sequence;
[0024] S25. Filter the initial word sequence, remove stop words, and obtain the word sequence after word segmentation.
[0025] In one embodiment, the word sequence is input into a pre-trained language model to obtain a sequence of context semantic vectors, including:
[0026] S31. Add special tags to the word sequence after word segmentation, and perform sub-word segmentation according to the requirements of the pre-trained language model to generate the model input sequence;
[0027] S32. Input the model input sequence into the pre-trained BERT model encoder;
[0028] S33. Encode the input sequence using the multi-layer Transformer structure of the BERT model encoder to obtain the output of its last hidden state.
[0029] S34. Extract the vector representation corresponding to the original valid word from the hidden state output. For a word consisting of multiple sub-words, take the hidden state corresponding to the first sub-word as the word representation to obtain the context semantic vector sequence.
[0030] In one embodiment, the context semantic vector sequence and the contract domain knowledge graph are linked to obtain a linking result. Based on the linking result, multi-hop neighbor information of relevant entities in the contract domain knowledge graph is aggregated to generate a knowledge-enhanced text feature vector sequence, including:
[0031] S41. For each word vector in the context semantic vector sequence, calculate its similarity with the embedding vectors of all entity names in the contract domain knowledge graph, and link words with similarity exceeding the threshold to the corresponding entities to obtain the entity link set.
[0032] S42. Based on the entity link set, extract the subgraph consisting of all linked entities and their one-hop and two-hop neighbors from the contract domain knowledge graph.
[0033] S43. Use a graph attention network to encode the subgraph, aggregate neighbor information, and obtain a knowledge-enhanced entity representation for each linked entity;
[0034] S44. For each lexical unit linked to an entity, the original context semantic vector is concatenated and linearly fused with the corresponding knowledge-enhanced entity representation to generate a knowledge-enhanced vector.
[0035] S45. For lexical units that are not linked to any knowledge graph entity, keep the original context semantic vector unchanged to obtain a knowledge-enhanced text feature vector sequence.
[0036] In one embodiment, structural features are extracted from the chapters of the contract file to obtain a document structure vector, including:
[0037] S51. Based on the parsed document format, identify the document elements and assign a type label to each document element; document elements include headings, chapters, paragraphs, lists, and signature areas;
[0038] S52. Analyze the hierarchical and sequential relationships between chapter elements and construct a document structure tree; where the root node of the document structure tree is the document, and the child nodes are chapters and paragraphs arranged in order.
[0039] S53. For each node in the document structure tree, extract structural features and normalize the structural features to obtain normalized node structural features; structural features include node type, depth, number of child nodes, and order in sibling nodes.
[0040] S54. Input the normalized node structure features into a multilayer perceptron for mapping to obtain node vector representations;
[0041] S55. Perform max pooling on the node vector representations of all nodes to aggregate global structural information and obtain the document structure vector.
[0042] In one embodiment, the knowledge-enhanced text feature vector sequence is aggregated and combined with the document structure vector. A multi-label classifier is then used to calculate the probability that the contract file document belongs to each preset category label, resulting in a classification result, including:
[0043] S61. Perform attention pooling on the knowledge-enhanced text feature vector sequence, calculate the importance weight of each word vector and perform weighted summation to obtain the document-level semantic vector;
[0044] S62. Concatenate the document-level semantic vector and the document structure vector to obtain the fused feature vector;
[0045] S63. Input the fused feature vector into a multilayer perceptron classifier and calculate the original score of the fused feature vector belonging to each preset classification label;
[0046] S64. Use the Sigmoid function to convert the original scores into probabilities, and determine the category label of the contract file document based on the probabilities and the predetermined classification threshold to obtain the classification result.
[0047] Secondly, this application also provides an automatic intelligent classification and identification system for contract archive resources, including:
[0048] The knowledge graph construction module is used to construct a contract domain knowledge graph based on historical contract archive texts and publicly available legal provisions through domain entity extraction and relationship mining; the contract domain knowledge graph includes legal concepts, business terms, and contract type entities;
[0049] The document parsing and preprocessing module is used to parse the format and extract the text of the contract archive documents to be classified, obtain the original text sequence, and clean and segment the original text sequence to obtain the segmented word sequence.
[0050] The semantic encoding module is used to input word sequences into a pre-trained language model to obtain a sequence of context semantic vectors.
[0051] The knowledge enhancement module is used to link the context semantic vector sequence and the contract domain knowledge graph to obtain the linking results, and to aggregate the multi-hop neighbor information of relevant entities in the contract domain knowledge graph based on the linking results to generate a knowledge-enhanced text feature vector sequence.
[0052] The structural feature extraction module is used to extract structural features from the chapters of contract archive documents to obtain document structure vectors;
[0053] The classification and recognition module is used to aggregate the knowledge-enhanced text feature vector sequence and combine it with the document structure vector. It then uses a multi-label classifier to calculate the probability that the contract file document belongs to each preset category label, and obtains the classification result.
[0054] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.
[0055] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.
[0056] The aforementioned method, system, device, and medium for automatic intelligent classification and recognition of contract archive resources effectively address the semantic comprehension bias problem caused by the lack of domain knowledge in traditional methods by constructing a domain knowledge graph that integrates legal and business knowledge and using a pre-trained language model to capture deep semantics. Furthermore, through entity linking and graph attention networks, the text semantics are deeply integrated with the structured concepts and relationships in the knowledge graph, enhancing the model's ability to recognize professional terms and their related logic. Simultaneously, the document's chapter structure features are extracted and integrated, enabling the model to understand the normative organizational form of contracts. Finally, by aggregating text semantics, domain knowledge, and structural features for multi-label classification, high-precision and robust automatic classification and recognition of medical contract archives are achieved, improving the accuracy and consistency of classification, reducing reliance on manual rules and experience, and meeting the needs of intelligent upgrades in hospital contract management. Attached Figure Description
[0057] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0058] Figure 1 This is a flowchart illustrating an automatic intelligent classification and identification method for contract archive resources in one embodiment;
[0059] Figure 2 This is a schematic diagram of the structure of an automatic intelligent classification and identification system for contract archive resources in one embodiment. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0061] refer to Figure 1 The document presents a flowchart illustrating an automatic intelligent classification and identification method for contract archive resources provided in this application. The method includes the following steps:
[0062] S1. Based on historical contract archives and publicly available legal provisions, a contract domain knowledge graph is constructed through domain entity extraction and relationship mining.
[0063] Optionally, the contract domain knowledge graph includes legal concepts, business terms, and contract type entities.
[0064] For example, historical contract archives are derived from various contracts generated by medical institutions during their operations, covering procurement contracts, technology cooperation contracts, research project contracts, service contracts, etc. Publicly available legal provisions include contract-related clauses in the Civil Code, and relevant regulations and normative documents in the medical industry. These texts undergo preliminary format standardization and content screening to remove invalid and duplicate text data to ensure data source quality. Domain entity extraction employs the BERT-BiLSTM-CRF named entity recognition model. This model first encodes the input text using a BERT pre-trained language model to obtain the contextual semantic vector of each character in the text. Then, the semantic vector is input into a bidirectional long short-term memory network to capture the sequence features of the text. Finally, a conditional random field model is used to annotate the sequence features, achieving accurate extraction of legal concepts, business terms, and contract type entities. Legal concepts cover breach of contract, force majeure, jurisdictional courts, and dispute resolution methods; business terms cover medical equipment procurement, drug distribution, research funding allocation, and clinical technology cooperation; and contract type entities cover procurement contracts, technology cooperation contracts, and research project contracts. Relation mining employs an attention-based relation extraction model. This model, based on domain entity extraction results, calculates the association weights between entity pairs through an attention mechanism to uncover semantic relationships between entities. Common relationships include inclusion, involvement, constraint, and attribution, such as the inclusion relationship between a procurement contract and a breach of contract clause, and the involvement relationship between a technology cooperation contract and research funding allocation. The contract domain knowledge graph is stored in a triple format, i.e., a combination of head entity, relation, and tail entity. A graph database is used to manage the knowledge graph to enable rapid querying of entity links and multi-hop neighbor information.
[0065] S2. Perform format parsing and text extraction on the contract archive documents to be classified to obtain the original text sequence. Then, clean and segment the original text sequence to obtain the segmented word sequence.
[0066] For example, the contract documents to be classified include PDF, Word, and scanned document formats. For PDF and Word documents, corresponding tool libraries are used for text extraction to directly obtain the character text from the documents. For scanned document formats, optical character recognition (OCR) technology is first used to convert image information into character text. A mature OCR model is selected to ensure the text extraction effect for different document formats. The original text sequence cleaning operation includes removing special symbols, whitespace characters, headers and footers, watermark text, page numbers, and other irrelevant information from the text. At the same time, duplicate text content is removed, and typos and formatting errors in the text are corrected using regular expressions to improve text quality from the source to ensure the effect of subsequent processing. Word segmentation is performed using a word segmentation tool combined with a custom dictionary. The custom dictionary includes medical industry professional terms and legal professional terms, such as medical equipment, drug centralized procurement, breach of contract liability, force majeure, etc. By loading the custom dictionary, errors in the segmentation of professional terms can be avoided during the word segmentation process, ensuring the integrity of professional terms, and finally obtaining the segmented word sequence.
[0067] S3. Input the word sequence into the pre-trained language model to obtain the context semantic vector sequence.
[0068] For example, the pre-trained language model uses a BERT model fine-tuned with corpus data from the medical contract domain. The fine-tuning corpus includes historical contract texts from medical institutions and relevant legal provisions. The fine-tuning process employs a masked language model task and a next-sentence prediction task to improve the model's semantic understanding of medical contract texts. The input format of the pre-trained language model consists of classification tags, word sequences, and delimiters. Classification tags represent the overall text semantics, and delimiters distinguish different text segments. The model captures the contextual semantic relationships between each word and other words in the word sequence through a multi-layer self-attention mechanism. The self-attention mechanism calculates attention weights between words and weights the semantic information of all words. The hidden layer output for each word is its contextual semantic vector. All contextual semantic vectors are arranged sequentially to obtain a sequence of contextual semantic vectors.
[0069] S4. Link the context semantic vector sequence and the contract domain knowledge graph to obtain the linking result. Then, based on the linking result, aggregate the multi-hop neighbor information of relevant entities in the contract domain knowledge graph to generate a knowledge-enhanced text feature vector sequence.
[0070] For example, the core of entity linking is to match and align the entities corresponding to words in the context semantic vector sequence with entities in the contract domain knowledge graph. Specifically, a vector similarity-based matching method is used to calculate the cosine similarity between the context semantic vector of a word and the embedding vector of the entity in the knowledge graph. The expression for cosine similarity is: In the formula Represents the cosine similarity value. The contextual semantic vector of the representative word, This represents the embedding vector of the corresponding entity in the knowledge graph. The magnitude of the context semantic vector. This represents the magnitude of the entity embedding vector. When the calculated cosine similarity is greater than a preset threshold, the entity corresponding to the word is considered to have successfully matched with an entity in the knowledge graph. The preset threshold can be adjusted according to actual classification needs. All successfully matched entity pairs constitute the link result. Multi-hop neighbor information aggregation is implemented using a graph attention network. For each successfully matched entity, its multi-hop neighbor entities and corresponding relationships are obtained from the knowledge graph. The graph attention network calculates the attention weights between the target entity and its neighbor entities, and then weights and aggregates the embedding vectors of the neighbor entities. The expression for the attention weights is: In the formula This represents the attention weight between the target entity and its neighboring entities. Represents the attention vector. Represents the weight matrix. Representative Entity The set of neighboring entities, This represents a vector concatenation operation. This represents the activation function, used to introduce non-linear features. The aggregated neighbor information is fused with the original word's context semantic vector using vector addition, achieved through the following formula: In the formula This represents the fused feature vector. The contextual semantic vector representing the original word. Represents attention weight, Represents the weight matrix. The embedding vector representing the neighboring entity. Representative Entity The set of neighboring entities. The fused vectors of all words are arranged in order to obtain a sequence of knowledge-enhanced text feature vectors.
[0071] S5. Extract structural features from the chapters of the contract archive document to obtain the document structure vector.
[0072] For example, contract documents have a fixed chapter structure, typically including modules such as title, contracting parties, contract subject matter, performance period, liability for breach of contract, and effective date. A method based on text position and keyword matching is used to segment the contract document into chapters. The title module is usually located at the beginning of the document and contains the word "contract." The contracting party module contains keywords such as "Party A," "Party B," and "contracting party." The contract subject matter module contains keywords such as "subject matter," "content," and "scope." These features allow for precise location of each chapter module. Chapter structure features encompass the text length, number of modules, order of appearance, and nesting relationships between modules. Simultaneously, vectors corresponding to key information of each module are extracted, such as the semantic vector of the title module and the entity vector of the contracting party module. These structural features are quantized and encoded. One-hot encoding is used to handle discrete features such as the number of modules and the order of appearance, while embedding encoding is used to handle continuous features such as module text length and semantic vectors. All quantized feature vectors are input into a fully connected layer for dimensionality reduction and integration. The fully connected layer uses ReLU as the activation function, outputting a document structure vector with uniform dimensionality.
[0073] S6. Aggregate the knowledge-enhanced text feature vector sequence and combine it with the document structure vector. Calculate the probability that the contract archive document belongs to each preset category label using a multi-label classifier to obtain the classification result.
[0074] For example, the knowledge-enhanced text feature vector sequence is aggregated using mean pooling, and the expression for mean pooling is: In the formula This represents the aggregated text feature vector. The length of the word sequence, This represents the feature vector of a single word after knowledge enhancement. The formula condenses the overall text features by averaging all word feature vectors. The aggregated text feature vector is then concatenated with the document structure vector to obtain a fused feature vector. The concatenation method uses direct vector concatenation, and the dimension of the fused feature vector is the sum of the dimensions of the text feature vector and the document structure vector. The multi-label classifier uses a structure of fully connected layers combined with a sigmoid activation function. The weight matrix of the fully connected layer is... The bias vector is ,in The preset number of category labels is set. These labels are determined based on the contract management needs of medical institutions and cover procurement contracts, technology cooperation contracts, research project contracts, service contracts, etc. The classifier's output is calculated using the following formula: In the formula This represents the set of probabilities that a contract document belongs to each of the preset category tags. This represents the sigmoid activation function, which maps the output value to the interval between 0 and 1. Represents the weight matrix of the fully connected layer. Represents the fused feature vector. This represents the bias vector. A probability threshold is set; when the probability corresponding to a certain category label is greater than or equal to the threshold, the contract document is determined to belong to that category label. All labels that meet the conditions constitute the final classification result of the contract document.
[0075] The aforementioned method for automatic intelligent classification and identification of contract archive resources effectively overcomes the limitations of traditional methods, such as insufficient understanding of professional terminology, weak semantic association capture ability, and lack of structural information utilization, by constructing a contract domain knowledge graph that integrates professional knowledge and synergistically utilizing the deep semantic information of the text and the chapter structure features of the document. It can deeply understand the complex legal and business semantics in medical contract texts, accurately capture the inherent relationship between contract type and core clauses and structural paradigms, thereby achieving efficient, accurate, and stable automated multi-label classification of hospital contract archives with diverse formats and professional content, improving the accuracy and intelligence level of classification, while enhancing the interpretability of model decisions, and meeting the high standards of hospitals for refined and knowledge-based management of massive contract archives.
[0076] In an optional embodiment, based on historical contract archives and publicly available legal provisions, a contract domain knowledge graph is constructed through domain entity extraction and relationship mining, including:
[0077] S11. The historical contract archives and publicly available legal texts are segmented and divided into sentences to obtain a set of text units.
[0078] Optionally, the segmentation operation is based on the inherent paragraph markers and chapter titles of the text, while also considering the formatting characteristics of medical contracts and legal provisions. Paragraphs that are too long are broken down according to semantic logic to avoid a single paragraph containing too many independent semantics. Sentence-level segmentation employs a rule-based and statistical approach, using punctuation marks such as periods, question marks, and exclamation marks as basic delimiters. For special punctuation marks commonly found in contract texts, such as ellipses and dashes, pre-defined rules determine whether segmentation is triggered, while excluding punctuation interference within quoted content and enumerated items. The segmentation process can be implemented using natural language processing tools to ensure that each segmented text unit corresponds to a complete semantic meaning, ultimately forming a set of text units composed of independent sentences, providing an accurate data source for subsequent entity extraction.
[0079] S12. Based on a predefined entity type dictionary and rules, extract legal concept entities and business term entities from the text unit set.
[0080] Optionally, the predefined entity type dictionary needs to be constructed in conjunction with the characteristics of the medical industry and the field of contract law. First, commonly used legal concepts and medical business terms in medical institution contracts are collected, and after review and calibration by domain experts, a basic dictionary is formed. Simultaneously, a dynamic update interface is reserved to allow for the addition of new terms. Rule design revolves around entity boundary identification and ambiguity elimination. For legal concept entities, sentence structure rules such as "attributive clause + core legal term" and "core legal term + complement" are set, for example, to identify entities such as "liability for breach of contract" and "force majeure clause." For medical business terms, terminology collocation rules are set in conjunction with industry standards to distinguish between professional terms such as "medical equipment" and "centralized drug procurement" and ordinary expressions, avoiding ambiguity. During the extraction process, candidate entities are initially located through dictionary matching, and then the rules are used to verify and filter the candidate entities, eliminating false positive matches and accurately extracting legal concept entities and business term entities.
[0081] S13. Based on the titles, summaries, and key clauses of historical contract archives, identify and define contract type entities using clustering algorithms.
[0082] Optionally, the title, summary, and key clauses are first extracted from historical contract archives. The title and summary directly reflect the core attributes of the contract, while the key clauses select core paragraphs that reflect the contract type, such as the subject matter, performance method, and contracting parties. Feature extraction is then performed on the extracted content, converting the text into feature vectors suitable for clustering. Feature dimensions include term frequency and semantic similarity. Density clustering or hierarchical clustering algorithms are used, dividing the data into clusters by calculating the semantic distance between samples. Each cluster corresponds to a contract type. After clustering, each cluster is manually labeled and defined based on domain business needs. For example, clusters containing features such as "medical equipment procurement" and "supply period" are defined as procurement contract entities, and clusters containing features such as "technical cooperation" and "research funding" are defined as technical cooperation contract entities, ultimately forming a standardized set of contract type entities.
[0083] S14. Based on legal concept entities, business term entities, and contract type entities, use a relational classification model to mine the relationships between entities and form a set of relational triples.
[0084] Optionally, the relationship classification model uses a pre-trained language model fine-tuning model. Taking the extracted three types of entities as the research objects, entity pair samples are constructed, with each sample containing two entities and corresponding context text. During model training, the entity pairs and context text are input into the pre-trained language model to obtain entity pair feature vectors incorporating context information. A classifier is then constructed using fully connected layers and activation functions to classify and identify relationships between entities. Recognizable relationships include inclusion, involvement, constraint, and attribution, such as the inclusion relationship between contract type entities and legal concept entities, and the involvement relationship between business term entities and contract type entities. After the model outputs the relationship category, it combines the corresponding entity pairs to form relationship triples in the form of <head entity, relationship, tail entity>. The accuracy of the relationships is ensured through manual sampling verification, forming a set of relationship triples.
[0085] S15. Import the legal concept entities, business term entities, contract type entities, and relation triples into the graph database to construct a knowledge graph for the contract domain.
[0086] Optionally, before importing, entities and triples are standardized in format, entity naming conventions are unified, and duplicate entities and invalid triples are removed to ensure data consistency. A database product supporting efficient graph querying and association analysis is selected for the graph database. The three types of entities are used as nodes in the graph, entity attributes are stored as node attributes, and relation triples are used as edges between nodes. The edge attributes record the relation type and related semantic descriptions. During the import process, data is written in batches through the database's provided interface, while entity and relation indexes are created to improve the efficiency of subsequent entity linking and multi-hop neighbor queries. After importing, the knowledge graph undergoes integrity and consistency checks. A graph traversal algorithm is used to check the rationality of relationships between entities, ensuring that the constructed contract domain knowledge graph can accurately support subsequent classification tasks.
[0087] In an optional embodiment, the contract documents to be classified are parsed and their text extracted to obtain an original text sequence. This original text sequence is then cleaned and segmented to obtain a segmented word sequence, including:
[0088] S21. Based on the file extension of the contract file, call the corresponding document parser to parse the format of the contract file and obtain the parsed document.
[0089] Optionally, document file extensions are directly associated with file storage formats, with different formats corresponding to specific parsing logic to adapt to their data storage structures. For common text file extensions, the corresponding format parser is called for binary stream parsing to extract structured data and unstructured text information from the document. During parsing, compatibility with different format versions must be ensured to avoid parsing distortion due to version differences. For image file extensions corresponding to scanned documents, an image format parser is called for format decoding, converting the image file into a standard image data format, providing a foundation for subsequent layout analysis and text extraction. After parsing, a format parsing document with a unified data structure is output to eliminate format differences between different source documents, facilitating subsequent standardization processing.
[0090] S22. Perform layout analysis on the parsed document, distinguish between text areas and non-text areas, extract character content from all text areas, and concatenate them to obtain the original text sequence.
[0091] Optionally, the layout analysis employs an algorithm based on the fusion of layout and pixel features, combined with the conventional typesetting patterns of contract documents, to perform region identification. Text area identification locates continuous character distribution areas based on factors such as pixel density, arrangement patterns, and font features, including effective text areas such as body paragraphs, titles, and signatures / descriptions. Non-text areas encompass areas without substantial semantic meaning, such as images, table borders, watermarks, page numbers, and header / footer decorative elements, which are distinguished from text areas through pixel grayscale differences and shape feature matching. For each identified text area, character content is extracted according to its spatial order within the document, preserving the semantic order within the text area during extraction to avoid character misalignment. The character content of all text areas is then sequentially concatenated to form a complete original text sequence, ensuring no effective text information is omitted.
[0092] S23. Clean the original text sequence to remove illegal characters, redundant spaces and format marks, and obtain a regular text sequence.
[0093] Optionally, illegal characters include invisible control characters, special symbols, and characters with abnormal encoding. Through preset character filtering rules and encoding verification mechanisms, characters exceeding the standard character set and lacking semantic value are identified and removed, while garbled characters caused by encoding errors are corrected. Redundant spaces include consecutive spaces, newlines, tabs, and other whitespace characters. Consecutive whitespace characters are replaced with single spaces using text normalization rules, and invalid whitespace at the beginning and end of lines is removed to maintain neat text formatting. Formatting tags cover format control tags and style identifiers left over from document parsing. A combination of regular expression matching and rule filtering is used to accurately identify and remove these tags, preventing them from interfering with subsequent word segmentation and semantic analysis. The resulting cleaned and normalized text sequence must ensure consistent character encoding, semantic coherence, and standardized formatting.
[0094] S24. Perform word segmentation on the regular text sequence to obtain the initial word sequence.
[0095] Optionally, word segmentation employs a fusion of dictionary matching and statistical language models, primarily relying on a custom dictionary adapted for the medical contract domain for basic word segmentation. This custom dictionary pre-includes medical industry terminology and contractual legal vocabulary, while also integrating commonly used collocations within the domain. Through a dual mechanism of forward matching and reverse verification from the dictionary, complete segmentation of professional terms is ensured, avoiding semantic loss due to fragmented segmentation. For words not covered by the dictionary, the optimal segmentation method is predicted based on contextual semantics using a statistical language model, balancing accuracy and completeness in word segmentation. During the segmentation process, the positional information and semantic association features of words in the text are recorded simultaneously, forming an initial word sequence containing complete semantic units, laying the foundation for subsequent filtering.
[0096] S25. Filter the initial word sequence, remove stop words, and obtain the word sequence after word segmentation.
[0097] Optionally, the stop word list is constructed by combining general stop words with domain-specific stop words. General stop words include auxiliary words, conjunctions, prepositions, etc., which lack substantial semantic meaning, while domain-specific stop words are selected specifically for medical contract scenarios, covering general expressions without classification value and recurring standardized guiding words. During the filtering process, each word in the initial word sequence is matched one by one with the stop word list, removing all successfully matched stop words while retaining core words with classification recognition, including professional terms, feature expressions, and key entities. After filtering, the remaining words are organized according to the semantic order of the original text to form the final word sequence after word segmentation, effectively reducing the amount of data processed by the subsequent model and improving the accuracy of feature extraction.
[0098] In an optional embodiment, the word sequence is input into a pre-trained language model to obtain a sequence of context semantic vectors, including:
[0099] S31. Add special tags to the word sequence after word segmentation, and perform sub-word segmentation according to the requirements of the pre-trained language model to generate the model input sequence.
[0100] Optionally, the addition of special markers strictly follows the input specifications of the pre-trained language model. A classification marker is added to the beginning of the word sequence for subsequent extraction of overall text semantic representation, and a separator marker is added to the end of the word sequence to mark the end boundary of the input text. Sub-word segmentation employs a byte-pair encoding algorithm. This algorithm, based on lexical statistics in the pre-training corpus, splits words not appearing in the model's vocabulary into included sub-word units. This approach adapts to variations in professional terminology in the medical contract domain while avoiding semantic loss due to out-of-vocabulary words. During the segmentation process, the mapping relationship between the original words and sub-words is recorded simultaneously to ensure that word-level semantic vectors can be reconstructed from the sub-word-level output, ultimately generating a sequence that conforms to the model's input format, balancing semantic integrity and model adaptability.
[0101] S32. Input the model input sequence into the pre-trained BERT model encoder.
[0102] Optionally, the pre-trained BERT model has undergone initial training on a large-scale general corpus, and subsequent fine-tuning and optimization using medical contract domain corpora. Its vocabulary has been expanded to accommodate medical and legal terminology, enabling better capture of domain-specific text semantics. During input, the model first performs word embedding encoding on each subword and special marker in the input sequence, converting discrete lexical symbols into continuous vector representations. Simultaneously, positional embedding information is incorporated to distinguish the different positions of words in the sequence, compensating for the self-attention mechanism's inability to perceive word order. If the input text length exceeds the model's preset maximum length, a combination of truncation and padding is used, prioritizing the preservation of core semantic paragraphs to ensure the input sequence length meets the encoder's requirements, laying the foundation for subsequent encoding processing.
[0103] S33. Encode the input sequence using the multi-layer Transformer structure of the BERT model encoder to obtain the output of the last hidden state.
[0104] Optionally, the Transformer structure is the core of the encoder, with each layer containing two key modules: a multi-head self-attention mechanism and a feedforward neural network. The multi-head self-attention mechanism uses multiple attention heads to compute in parallel, capturing the contextual relationships between each word and all other words in the sequence. Different attention heads can focus on semantic relationships in different dimensions, such as word collocation and semantic dependencies. The feedforward neural network performs non-linear transformations on the feature vectors output by the self-attention mechanism, enhancing the feature representation capability. The multi-layer Transformer structure, through a progressively layered encoding approach, gradually mines the deep semantic information of the text. Compared to a single-layer structure, it can more accurately capture the complex semantic relationships in medical contract texts. The final hidden state output integrates the contextual information of the entire sequence and deep semantic features.
[0105] S34. Extract the vector representation corresponding to the original valid word from the hidden state output. For a word consisting of multiple sub-words, take the hidden state corresponding to the first sub-word as the word representation to obtain the context semantic vector sequence.
[0106] Optionally, the extraction process relies on the recorded mapping relationship between original words and sub-words, matching the sub-word vectors in the hidden state output with the original word units one by one. For an original word unit corresponding to only a single sub-word, the hidden state of that sub-word is directly extracted as its semantic vector; for an original word unit that has been split into multiple sub-words, the hidden state of the first sub-word is selected as the semantic representation of the entire word unit. This is because the hidden state of the first sub-word already contains the core semantic information of that word unit and can accurately correspond to the boundary of the original word unit, avoiding semantic shifts caused by the fusion of multiple sub-word vectors. After extraction, the vector representations of all word units are organized according to the semantic order of the original word sequence to form a context semantic vector sequence, providing vector support for subsequent entity linking operations with the contract domain knowledge graph.
[0107] In an optional embodiment, the context semantic vector sequence and the contract domain knowledge graph are linked to obtain a linking result. Based on the linking result, multi-hop neighbor information of relevant entities in the contract domain knowledge graph is aggregated to generate a knowledge-enhanced text feature vector sequence, including:
[0108] S41. For each word vector in the context semantic vector sequence, calculate its similarity with the embedding vectors of all entity names in the contract domain knowledge graph, and link words with similarity exceeding the threshold to the corresponding entities to obtain the entity link set.
[0109] Optionally, a word vector is a single vector in the context semantic vector sequence, which has already incorporated the context semantic information of the corresponding word. Entity name embedding vectors in the knowledge graph are generated through encoding using a pre-trained language model that is homologous to the word vectors, ensuring consistency in their vector spaces and providing a foundation for similarity calculation. Cosine similarity is used for similarity calculation, and the threshold needs to be set in conjunction with the entity distribution characteristics and classification accuracy requirements in the medical contract domain. The optimal value is determined through experimental calibration to avoid false links caused by excessively low thresholds and missed links caused by excessively high thresholds. For each word vector, the similarity is calculated by traversing all entity name embedding vectors in the knowledge graph. Entities exceeding the threshold are considered candidate link objects. If multiple candidate entities exist, the entity with the highest similarity is selected to establish a link, ultimately forming a set of entity links consisting of words and their corresponding entities.
[0110] S42. Based on the entity link set, extract the subgraph consisting of all linked entities and their one-hop and two-hop neighbors from the contract domain knowledge graph.
[0111] Optionally, the linked entity refers to the knowledge graph entity in the entity link set that has successfully established a link with the term. The node positions of these entities in the knowledge graph are first quickly located using a graph database index. One-hop neighbor entities refer to entities that have a direct relation to the linked entity, and two-hop neighbor entities refer to entities that have a direct relation to one-hop neighbor entities but are not included in the linked entity or one-hop neighbor entities. These are extracted sequentially according to the relation hierarchy using a graph traversal algorithm. During the extraction process, the relation types and association attributes between entities are preserved simultaneously to ensure that the subgraph completely restores the local association structure of the linked entities in the original knowledge graph. The subgraph is constructed with the linked entity as the core, integrating one-hop and two-hop neighbor entities and the relation edges between entities, and removing redundant nodes and edges that have no direct or indirect relation to the linked entity. This preserves sufficient contextual knowledge while controlling the size of the subgraph to improve subsequent encoding efficiency, providing structured data support for neighbor information aggregation.
[0112] S43. Use a graph attention network to encode the subgraph, aggregate neighbor information, and obtain a knowledge-enhanced entity representation for each linked entity.
[0113] Optionally, the graph attention network, as the core model for subgraph encoding, can adaptively capture the association weights between entities and their neighbors, strengthening the influence of important neighbor information. During the encoding process, the embedding vectors of all entities in the subgraph are first used as initial input. The initial vectors are then linearly transformed using a weight matrix to unify feature dimensions and enhance expressive power. Subsequently, a multi-head self-attention mechanism is used to calculate the attention weights between each entity and its neighbors. Based on these attention weights, the transformed vectors of neighboring entities are weighted and aggregated. The aggregated result is then fused with the transformed vector of the target entity itself to obtain a preliminary enhanced representation for each entity. This process is repeated through a multi-layer graph attention network, gradually integrating the semantic knowledge of multi-hop neighbors, and finally outputting a knowledge-enhanced entity representation for each linked entity. This representation integrates its own semantics with the association knowledge of multi-hop neighbors.
[0114] S44. For each lexical unit linked to an entity, the original context semantic vector is concatenated and linearly fused with the corresponding knowledge-enhanced entity representation to generate a knowledge-enhanced vector.
[0115] Optionally, the original contextual semantic vector retains the contextual information of the word in the contract text, while the knowledge-enhanced entity representation supplements the associated knowledge of the corresponding entity in the knowledge graph. The fusion of these two elements achieves complementarity between textual context and domain knowledge. The concatenation operation uses a direct vector concatenation method, superimposing the original contextual semantic vector and the knowledge-enhanced entity representation dimensionally to form a concatenated vector with a dimension equal to the sum of the two. Linear fusion is achieved by introducing a learnable weight matrix and bias vector, performing linear transformation and non-linear activation on the concatenated vector to automatically adjust the contribution weights of the two vectors, making the fusion result more suitable for subsequent classification tasks. Normalization is introduced simultaneously during the fusion process to avoid feature imbalance caused by differences in vector dimensions. The final generated knowledge-enhanced vector contains both the textual contextual features of the word and incorporates domain knowledge features, improving the recognizability and expressive power of the word features.
[0116] S45. For lexical units that are not linked to any knowledge graph entity, keep the original context semantic vector unchanged to obtain a knowledge-enhanced text feature vector sequence.
[0117] Optionally, the lexical units not linked to entities in the knowledge graph are mostly general vocabulary, modal particles, or newly added words not included in the domain. Their original contextual semantic vectors can already fully represent their semantic information, and no additional knowledge is needed. In the processing, all lexical units in the contextual semantic vector sequence are first traversed, and those without established links are selected based on the entity link set, directly retaining their original contextual semantic vectors. Then, according to the semantic order of the original word sequence, the knowledge-enhanced vectors corresponding to all linked lexical units are sequentially arranged with the original contextual semantic vectors corresponding to the unlinked lexical units, forming a complete knowledge-enhanced text feature vector sequence. This sequence strengthens the feature expression of core lexical units through knowledge fusion while retaining the basic semantic information of non-core lexical units, providing high-quality feature input for subsequent text feature aggregation and classification processing.
[0118] In an optional embodiment, structural features are extracted from the chapters of the contract archive document to obtain a document structure vector, including:
[0119] S51. Based on the parsed document format, identify the document elements in the document and assign a type label to each document element.
[0120] Optionally, chapter elements include titles, chapters, paragraphs, lists, and signature areas.
[0121] Optionally, the parsed document eliminates format differences while retaining the original document's layout information and content hierarchy, providing basic data support for document element recognition. The recognition process employs an algorithm that integrates layout and content features, combined with the formatting specifications of medical contract documents for precise positioning. Title elements are identified through font size, weight, position features, and content keywords. Typically, title fonts are larger than the body text, often bold, and located at the beginning of a chapter, while containing core words such as "contract" and "clauses." Chapter elements are identified by chapter numbers (such as "Article 1," "1.") or specific title styles, distinguishing them from ordinary paragraphs. Paragraph elements are identified based on features such as text wrapping, paragraph spacing, and the absence of special formatting marks, serving as the main carrier of the body text. List elements are determined by bullet points, numbering sequences, and parallel content relationships, commonly found in scenarios such as enumeration of obligations and itemized clauses in contracts. Signature areas are mostly located at the end of the document, identified by combining keywords such as "Party A," "Party B," "signature," and "date," as well as fixed formatting positions. After identification, a unique type label is assigned to each document element. The label adopts a standardized encoding format to ensure the consistency of subsequent structural analysis, forming a corresponding set of "document element - type label".
[0122] S52. Analyze the hierarchical and sequential relationships between chapter elements and construct the document structure tree.
[0123] Optionally, the root node of the document structure tree is the document, and the child nodes are chapters and paragraphs arranged in sequence.
[0124] Optionally, the hierarchical relationship parsing is based on the positional information, format nesting features, and content logic of the chapter elements, employing a top-down traversal approach. Chapter elements serve as the core hierarchical carriers, and can nest sub-chapters, paragraphs, lists, etc., forming parent-child hierarchical relationships. The signature area exists independently of the main text level as a sibling element under the root node. Paragraphs and list elements are mostly child elements of chapters, with some independent paragraphs directly belonging to the root node. The sequential relationship strictly follows the spatial arrangement order in the document, sorting elements at the same level sequentially according to a left-to-right, top-to-bottom reading logic, ensuring that the structure tree restores the original document layout order. The document structure tree is stored using a tree-like data structure. The root node represents the entire contract document, each node is associated with corresponding chapter elements and type tags, and child nodes are mounted sequentially according to the parsed order. Hierarchical relationships are recorded through parent node pointers and child node lists, completely preserving the hierarchical nesting relationships of chapter elements while accurately restoring the sequential logic between elements, providing structured support for subsequent node feature extraction.
[0125] S53. For each node in the document structure tree, extract structural features and normalize the structural features to obtain normalized node structural features.
[0126] Optionally, structural features include node type, depth, number of child nodes, and order among sibling nodes.
[0127] Optionally, node type features are extracted based on assigned type labels and converted into discrete numerical features using one-hot encoding. Different type labels correspond to different encoding vectors to distinguish the attribute differences of elements such as titles, chapters, and paragraphs. Node depth features refer to the hierarchical distance of a node relative to the root node. The root node depth is set to 0, and its direct child node depth is 1, and so on. The depth value of each node is calculated by traversing the tree structure, reflecting the element's position in the document hierarchy. The child node quantity feature counts the total number of child nodes directly attached to each node, reflecting the node's content carrying capacity. For example, the number of child nodes of a chapter node can reflect the richness of the chapter's content. The order feature in sibling nodes refers to the ranking of the current node among all child nodes under the same parent node. Values are assigned according to a defined order relationship, reflecting the element's relative position within the same level. Normalization is performed to address the differences in the numerical range of different features. Discrete features do not require additional normalization after one-hot encoding. Continuous features (depth, number of child nodes, ordinal position) are normalized using the min-max normalization method to map the values to a fixed interval, eliminate the influence of dimensions, ensure the balance of the weights of each feature, and provide standardized feature inputs for subsequent vector mapping.
[0128] S54. Input the normalized node structure features into a multilayer perceptron for mapping to obtain the node vector representation.
[0129] Optionally, the multilayer perceptron, as the core model for feature mapping, adopts a fully connected network structure consisting of an input layer, hidden layers, and an output layer, adapting to the dimensionality of the normalized structural features and the output requirements of the node vectors. The number of neurons in the input layer is consistent with the total dimension of the normalized structural features, using the standardized node structural feature vectors as input data. The hidden layer has a multi-layer structure, with the number of neurons in each layer determined through experimental calibration. The ReLU activation function is used to introduce non-linear feature transformation capabilities, enhancing feature expression, while the dropout mechanism suppresses overfitting and improves the model's generalization ability. The number of neurons in the output layer corresponds to the preset node vector dimension, and the output dimension needs to be adapted to the dimension of the subsequent text feature vectors to ensure the feasibility of subsequent fusion operations. During the mapping process, the multilayer perceptron iteratively optimizes the weight matrix and bias vector through the backpropagation algorithm, minimizing the feature mapping error and converting high-dimensional discrete structural features into low-dimensional continuous node vector representations. Each node vector incorporates the complete structural information of the corresponding text elements, achieving a numerical and compact expression of structural features.
[0130] S55. Perform max pooling on the node vector representations of all nodes to aggregate global structural information and obtain the document structure vector.
[0131] Optionally, max pooling is performed on the vector representations of all nodes. Its core purpose is to extract global key structural information from the local structural features of each node, while simultaneously compressing data dimensionality to avoid redundancy. During the operation, the node vectors are traversed dimension by dimension, and the maximum value for each node in the same dimension is taken as the final value for that dimension. This process is repeated for all dimensions to form the global structure vector. The advantage of max pooling is that it effectively preserves salient features in each dimension, highlighting the structural influence of key document elements (such as core chapters and titles), weakening the interference of secondary elements, and more accurately capturing the overall structural features of the contract document. The final output document structure vector has the same dimension as the individual node vector, integrating local structural information such as the hierarchy, order, and type of document elements while also condensing global structural features, providing high-quality structural feature support for subsequent fusion with text feature vectors and classification tasks.
[0132] In an optional embodiment, the knowledge-enhanced text feature vector sequence is aggregated and combined with the document structure vector. A multi-label classifier is then used to calculate the probability that the contract file document belongs to each preset category label, yielding the classification result, including:
[0133] S61. Perform attention pooling on the knowledge-enhanced text feature vector sequence, calculate the importance weight of each word vector and perform weighted summation to obtain the document-level semantic vector.
[0134] Optionally, attention pooling, compared to traditional mean pooling, can adaptively distinguish the contribution of different word vectors to document classification, strengthen the influence of core word features, and weaken the interference of irrelevant words. The calculation process first uses the knowledge-enhanced text feature vector sequence as input, and generates an attention score for each word vector through a single hidden-layer neural network. This neural network uses ReLU as the activation function to map word vectors to one-dimensional score values, representing the initial importance of the word. Then, the attention scores of all words are normalized using the Softmax function to obtain the importance weight of each word vector, ensuring that the sum of all weights is 1. A higher weight value indicates a greater contribution of the corresponding word to document classification. The weighted summation process is based on word vectors, multiplying each word vector by its corresponding importance weight, and then summing all the product results to obtain a document-level semantic vector that integrates global text semantics and core word features. This vector dimension is consistent with the dimension of a single knowledge-enhanced word vector, providing unified dimensional support for subsequent feature fusion.
[0135] S62. Concatenate the document-level semantic vector and the document structure vector to obtain the fused feature vector.
[0136] Optionally, the document-level semantic vector focuses on the core semantic features at the text content level, encompassing knowledge-enhanced lexical association information and domain knowledge; the document structure vector represents the document's chapter layout and hierarchical logical features. The fusion of these two features achieves complementarity between content and structural features, improving the accuracy of the classification model. The concatenation operation is performed using a dimension stacking method, directly concatenating the document-level semantic vector and the document structure vector in sequence to form a fused feature vector. The dimension of the fused feature vector is the sum of the dimensions of the document-level semantic vector and the document structure vector. Before concatenation, it is necessary to ensure that the numerical ranges of the two vectors are consistent, and normalization is used to eliminate dimensional differences, avoiding excessive proportion of a single feature dimension leading to model bias. The fused feature vector after concatenation contains both the core semantic information of the contract text and integrates the document's structural features, comprehensively covering the key feature dimensions required for classification, providing sufficient feature support for subsequent classification calculations.
[0137] S63. Input the fused feature vector into a multilayer perceptron classifier and calculate the original score of the fused feature vector belonging to each preset classification label.
[0138] Optionally, a multilayer perceptron classifier serves as the core classification module, employing a fully connected network structure consisting of an input layer, several hidden layers, and an output layer. This structure adapts to the dimensionality of the fused feature vector and the required number of predefined classification labels. The number of neurons in the input layer is identical to the dimensionality of the fused feature vector, using the normalized fused feature vector as input data to ensure complete feature transmission to the network for processing. The hidden layers employ a multi-layered progressive structure, with the number of neurons in each layer determined through experimental calibration. This progressively performs nonlinear transformations and dimensionality compression on the input features. The ReLU activation function is chosen to introduce nonlinear feature representation capabilities. A dropout mechanism is added between hidden layers to randomly discard some neuron connections, suppressing overfitting and improving the model's generalization ability for unknown contract documents. The number of neurons in the output layer is identical to the number of predefined classification labels, with each neuron corresponding to one label. The output is the raw score of the fused feature vector for each classification label. The raw score has no fixed numerical range and directly reflects the degree of matching between the features and the labels.
[0139] S64. Use the Sigmoid function to convert the original scores into probabilities, and determine the category label of the contract file document based on the probabilities and the predetermined classification threshold to obtain the classification result.
[0140] Optionally, the sigmoid function, as an activation function, primarily maps the raw scores obtained from the output layer to a range of 0 to 1, converting them into probability values for the corresponding classification labels. The closer the probability value is to 1, the higher the likelihood that the contract document belongs to that label; the closer it is to 0, the lower the likelihood. The sigmoid function is calculated using the following formula: In the formula This represents the transformed probability value. This represents the raw score output by the multilayer perceptron. This function effectively distinguishes the probability differences between different labels, adapting to the requirement that multiple labels can be valid simultaneously in multi-label classification scenarios. The predetermined classification threshold needs to be set in conjunction with the accuracy requirements of medical institution contract classification and actual business scenarios. The optimal value is determined through experiments with a large number of historical contract samples to balance classification accuracy and recall. During the judgment process, the probability value corresponding to each classification label is compared with the predetermined threshold. If the probability value is greater than or equal to the threshold, the contract document is determined to belong to that label; if it is less than the threshold, the label is excluded. All labels that meet the conditions constitute the final classification result of the contract document. If multiple labels meet the conditions, they are all retained to adapt to cross-category attribute scenarios that may exist in medical contracts.
[0141] The aforementioned method for automatic intelligent classification and recognition of contract archive resources effectively overcomes the shortcomings of traditional methods, such as relying on shallow keywords, lack of domain knowledge understanding, and neglect of document structure, by constructing a knowledge graph of the contract domain and cleverly integrating the deep semantics of documents, domain professional knowledge, and textual structure information. This method utilizes the knowledge graph to embed rich domain entities and relationships, and enhances the accuracy and contextual relevance of text representation through entity links and graph attention networks. Simultaneously, it extracts and integrates the inherent hierarchical structural features of documents, enabling the model to more comprehensively understand contract documents. Finally, by integrating multiple features for multi-label classification, it improves the accuracy, robustness, and semantic understanding of professional terms and complex clauses in automatic contract archive classification, achieving high-precision, high-efficiency, and highly adaptable intelligent classification to meet the hospital's needs for automated and intelligent management of massive and specialized contract archives.
[0142] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0143] Based on the same inventive concept, this application also provides an automatic intelligent classification and recognition system for contract archive resources to implement the above-mentioned automatic intelligent classification and recognition method for contract archive resources. The solution provided by this system is similar to the implementation scheme described in the above method. Therefore, the specific limitations of one or more embodiments of the automatic intelligent classification and recognition system for contract archive resources provided below can be found in the limitations of the automatic intelligent classification and recognition method for contract archive resources described above, and will not be repeated here.
[0144] In one exemplary embodiment, such as Figure 2 As shown, a schematic diagram of the structure of an automatic intelligent classification and recognition system 10 for contract archive resources is provided, including:
[0145] The knowledge graph construction module 11 is used to construct a contract domain knowledge graph based on historical contract archive texts and publicly available legal provisions through domain entity extraction and relationship mining; the contract domain knowledge graph includes legal concepts, business terms and contract type entities;
[0146] The document parsing and preprocessing module 12 is used to perform format parsing and text extraction on the contract archive documents to be classified, to obtain the original text sequence, and to clean and segment the original text sequence to obtain the segmented word sequence.
[0147] Semantic encoding module 13 is used to input word sequences into a pre-trained language model to obtain a sequence of context semantic vectors;
[0148] The knowledge enhancement module 14 is used to link the context semantic vector sequence and the contract domain knowledge graph to obtain the linking result, and to aggregate the multi-hop neighbor information of relevant entities in the contract domain knowledge graph based on the linking result to generate a knowledge-enhanced text feature vector sequence.
[0149] The structural feature extraction module 15 is used to extract structural features from the chapters of the contract archive document to obtain the document structure vector;
[0150] The classification and recognition module 16 is used to aggregate the knowledge-enhanced text feature vector sequence and combine it with the document structure vector. It then uses a multi-label classifier to calculate the probability that the contract file document belongs to each preset category label to obtain the classification result.
[0151] Furthermore, the knowledge graph construction module 11 is also used for:
[0152] S11. Segment and sentence-level segmentation of historical contract archives and publicly available legal provisions to obtain a set of text units;
[0153] S12. Based on a predefined entity type dictionary and rules, extract legal concept entities and business term entities from the text unit set;
[0154] S13. Based on the titles, summaries, and key clauses of historical contract archives, identify and define contract type entities using clustering algorithms;
[0155] S14. Based on legal concept entities, business term entities, and contract type entities, use a relational classification model to mine the relationships between entities and form a set of relational triples.
[0156] S15. Import the legal concept entities, business term entities, contract type entities, and relation triples into the graph database to construct a knowledge graph for the contract domain.
[0157] Furthermore, the document parsing and preprocessing module 12 is also used for:
[0158] S21. Based on the file extension of the contract file, call the corresponding document parser to parse the format of the contract file and obtain the parsed document.
[0159] S22. Perform layout analysis on the document after format parsing, distinguish between text areas and non-text areas, extract character content from all text areas, and concatenate them to obtain the original text sequence.
[0160] S23. Clean the original text sequence to remove illegal characters, redundant spaces and format marks, and obtain a regular text sequence.
[0161] S24. Perform word segmentation on the regular text sequence to obtain the initial word sequence;
[0162] S25. Filter the initial word sequence, remove stop words, and obtain the word sequence after word segmentation.
[0163] Furthermore, the semantic encoding module 13 is also used for:
[0164] S31. Add special tags to the word sequence after word segmentation, and perform sub-word segmentation according to the requirements of the pre-trained language model to generate the model input sequence;
[0165] S32. Input the model input sequence into the pre-trained BERT model encoder;
[0166] S33. Encode the input sequence using the multi-layer Transformer structure of the BERT model encoder to obtain the output of its last hidden state.
[0167] S34. Extract the vector representation corresponding to the original valid word from the hidden state output. For a word consisting of multiple sub-words, take the hidden state corresponding to the first sub-word as the word representation to obtain the context semantic vector sequence.
[0168] Furthermore, the knowledge enhancement module 14 is also used for:
[0169] S41. For each word vector in the context semantic vector sequence, calculate its similarity with the embedding vectors of all entity names in the contract domain knowledge graph, and link words with similarity exceeding the threshold to the corresponding entities to obtain the entity link set.
[0170] S42. Based on the entity link set, extract the subgraph consisting of all linked entities and their one-hop and two-hop neighbors from the contract domain knowledge graph.
[0171] S43. Use a graph attention network to encode the subgraph, aggregate neighbor information, and obtain a knowledge-enhanced entity representation for each linked entity;
[0172] S44. For each lexical unit linked to an entity, the original context semantic vector is concatenated and linearly fused with the corresponding knowledge-enhanced entity representation to generate a knowledge-enhanced vector.
[0173] S45. For lexical units that are not linked to any knowledge graph entity, keep the original context semantic vector unchanged to obtain a knowledge-enhanced text feature vector sequence.
[0174] Furthermore, the structural feature extraction module 15 is also used for:
[0175] S51. Based on the parsed document format, identify the document elements and assign a type label to each document element; document elements include headings, chapters, paragraphs, lists, and signature areas;
[0176] S52. Analyze the hierarchical and sequential relationships between chapter elements and construct a document structure tree; where the root node of the document structure tree is the document, and the child nodes are chapters and paragraphs arranged in order.
[0177] S53. For each node in the document structure tree, extract structural features and normalize the structural features to obtain normalized node structural features; structural features include node type, depth, number of child nodes, and order in sibling nodes.
[0178] S54. Input the normalized node structure features into a multilayer perceptron for mapping to obtain node vector representations;
[0179] S55. Perform max pooling on the node vector representations of all nodes to aggregate global structural information and obtain the document structure vector.
[0180] Furthermore, the classification and recognition module 16 is also used for:
[0181] S61. Perform attention pooling on the knowledge-enhanced text feature vector sequence, calculate the importance weight of each word vector and perform weighted summation to obtain the document-level semantic vector;
[0182] S62. Concatenate the document-level semantic vector and the document structure vector to obtain the fused feature vector;
[0183] S63. Input the fused feature vector into a multilayer perceptron classifier and calculate the original score of the fused feature vector belonging to each preset classification label;
[0184] S64. Use the Sigmoid function to convert the original scores into probabilities, and determine the category label of the contract file document based on the probabilities and the predetermined classification threshold to obtain the classification result.
[0185] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the automatic intelligent classification and identification method for contract file resources as described above.
[0186] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0187] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The components described as separate parts may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this disclosure according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0188] The above-described embodiments are merely illustrative of several implementation methods of the embodiments of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the embodiments of this application, and these modifications and improvements all fall within the protection scope of the embodiments of this application.
Claims
1. A method for automatic intelligent classification and identification of contract archive resources, characterized in that, The method includes: S1. Based on historical contract archives and publicly available legal provisions, a contract domain knowledge graph is constructed through domain entity extraction and relationship mining; wherein, the contract domain knowledge graph includes legal concepts, business terms, and contract type entities; S2. Perform format parsing and text extraction on the contract archive documents to be classified to obtain the original text sequence, and then clean and segment the original text sequence to obtain the segmented word sequence. S3. Input the word sequence into the pre-trained language model to obtain the context semantic vector sequence; S4. Link the context semantic vector sequence and the contract domain knowledge graph to obtain the linking result, and aggregate the multi-hop neighbor information of relevant entities in the contract domain knowledge graph according to the linking result to generate a knowledge-enhanced text feature vector sequence. S5. Extract structural features from the chapters of the contract archive document to obtain a document structure vector; S6. Aggregate the knowledge-enhanced text feature vector sequence and combine it with the document structure vector. Calculate the probability that the contract file document belongs to each preset category label using a multi-label classifier to obtain the classification result.
2. The method according to claim 1, characterized in that, Based on historical contract archives and publicly available legal provisions, a contract domain knowledge graph is constructed through domain entity extraction and relationship mining, including: S11. The historical contract archive text and publicly available legal provisions are segmented and sentence-level divided to obtain a set of text units; S12. Based on a predefined entity type dictionary and rules, extract legal concept entities and business term entities from the text unit set; S13. Based on the title, summary, and key clauses of the historical contract archive text, identify and define contract type entities using a clustering algorithm; S14. Based on the legal concept entities, business term entities, and contract type entities, use a relational classification model to mine the relationships between entities and form a set of relational triples. S15. Import the legal concept entities, business term entities, contract type entities, and relation triple sets into a graph database to construct the contract domain knowledge graph.
3. The method according to claim 1, characterized in that, The process involves parsing and extracting the format of the contract documents to be classified to obtain an original text sequence. This original text sequence is then cleaned and segmented to obtain a segmented word sequence, including: S21. Based on the file extension of the contract file, call the corresponding document parser to parse the format of the contract file and obtain the parsed document. S22. Perform layout analysis on the document after parsing the format, distinguish between text areas and non-text areas, extract character content from all text areas, and concatenate them to obtain the original text sequence. S23. Clean the original text sequence to remove illegal characters, redundant spaces and format marks, and obtain a regular text sequence. S24. Perform word segmentation on the regularized text sequence to obtain an initial word sequence; S25. Filter the initial word sequence, remove stop words, and obtain the segmented word sequence.
4. The method according to claim 1, characterized in that, The step of inputting the word sequence into a pre-trained language model to obtain a context semantic vector sequence includes: S31. Add special markers to the segmented word sequence and perform sub-word segmentation according to the requirements of the pre-trained language model to generate the model input sequence; S32. Input the model input sequence into the pre-trained BERT model encoder; S33. Encode the input sequence through the multi-layer Transformer structure of the BERT model encoder to obtain the output of its last hidden state. S34. Extract the vector representation corresponding to the original valid word from the output of the hidden state. For a word composed of multiple sub-words, take the hidden state corresponding to the first sub-word as the representation of the word to obtain the context semantic vector sequence.
5. The method according to claim 1, characterized in that, The step of linking the context semantic vector sequence and the contract domain knowledge graph to obtain a linking result, and then aggregating the multi-hop neighbor information of relevant entities in the contract domain knowledge graph based on the linking result to generate a knowledge-enhanced text feature vector sequence, includes: S41. For each word vector in the context semantic vector sequence, calculate its similarity with all entity name embedding vectors in the contract domain knowledge graph, and link words with similarity exceeding the threshold to the corresponding entities to obtain an entity link set. S42. Based on the entity link set, extract the subgraph composed of all linked entities and their one-hop and two-hop neighbors from the contract domain knowledge graph; S43. Encode the subgraph using a graph attention network, aggregate neighbor information, and obtain a knowledge-enhanced entity representation for each linked entity; S44. For each lexical unit linked to an entity, the original context semantic vector and the corresponding knowledge-enhanced entity representation are concatenated and linearly fused to generate a knowledge-enhanced vector. S45. For lexical units that are not linked to any knowledge graph entity, keep the original context semantic vector unchanged to obtain the knowledge-enhanced text feature vector sequence.
6. The method according to claim 1, characterized in that, The extraction of structural features from the chapters of the contract archive document to obtain a document structure vector includes: S51. Based on the parsed document, identify the chapter elements in the document and assign a type label to each chapter element; the chapter elements include titles, chapters, paragraphs, lists, and signature areas; S52. Analyze the hierarchical and sequential relationships between the chapter elements and construct a document structure tree; wherein the root node of the document structure tree is the document, and the child nodes are chapters and paragraphs arranged in order. S53. For each node in the document structure tree, extract structural features and normalize the structural features to obtain normalized node structural features; the structural features include node type, depth, number of child nodes, and order in sibling nodes. S54. Input the normalized node structure features into a multilayer perceptron for mapping to obtain node vector representations; S55. Perform max pooling on the node vector representations of all nodes to aggregate global structural information and obtain the document structure vector.
7. The method according to claim 1, characterized in that, The process involves aggregating the knowledge-enhanced text feature vector sequence and combining it with the document structure vector. A multi-label classifier is then used to calculate the probability that the contract file document belongs to each preset category label, yielding a classification result, including: S61. Perform attention pooling on the knowledge-enhanced text feature vector sequence, calculate the importance weight of each word vector and perform weighted summation to obtain a document-level semantic vector; S62. Concatenate the document-level semantic vector and the document structure vector to obtain a fused feature vector; S63. Input the fused feature vector into a multilayer perceptron classifier and calculate the original score of the fused feature vector belonging to each preset classification label; S64. Use the Sigmoid function to convert the original score into a probability, and determine the belonging label of the contract file document according to the probability and a predetermined classification threshold to obtain the classification result.
8. An automatic intelligent classification and identification system for contract archive resources, characterized in that, The system includes: The knowledge graph construction module is used to construct a contract domain knowledge graph based on historical contract archive texts and publicly available legal provisions through domain entity extraction and relationship mining; wherein, the contract domain knowledge graph includes legal concepts, business terms and contract type entities; The document parsing and preprocessing module is used to perform format parsing and text extraction on the contract archive documents to be classified, to obtain the original text sequence, and to clean and segment the original text sequence to obtain the segmented word sequence. The semantic encoding module is used to input the word sequence into a pre-trained language model to obtain a sequence of context semantic vectors; The knowledge enhancement module is used to link the context semantic vector sequence and the contract domain knowledge graph to obtain the linking result, and to aggregate the multi-hop neighbor information of relevant entities in the contract domain knowledge graph according to the linking result to generate a knowledge-enhanced text feature vector sequence. The structural feature extraction module is used to extract structural features from the chapters of the contract archive document to obtain a document structure vector; The classification and recognition module is used to aggregate the knowledge-enhanced text feature vector sequence and, in conjunction with the document structure vector, calculate the probability that the contract file document belongs to each preset category label through a multi-label classifier to obtain the classification result.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 7.