Document directory error repair method and system based on multi-model cooperation

By employing a multi-model collaborative approach, the problem of automated directory repair for Markdown format files was solved, achieving efficient and accurate directory repair and improving document processing efficiency and quality.

CN120893402BActive Publication Date: 2026-02-03WHALE CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511409007.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-29
Publication Date
2026-02-03
Estimated Expiration
2045-09-29

AI Technical Summary

Technical Problem

Existing technologies for handling table of contents errors in Markdown files suffer from problems such as inaccurate title recognition, non-standard formatting, frequent recognition errors in complex document structures, and a lack of clear standards. These issues result in high manual costs, low efficiency, and negatively impact document readability and maintainability.

Method used

An automated catalog error repair method is achieved by employing a multi-model collaborative approach, utilizing graph structure representation, graph convolutional neural networks, multi-head cross-attention mechanism, sequence generation model, and dynamic programming algorithm.

Benefits of technology

It significantly improves the efficiency and accuracy of Markdown table of contents repair, reduces labor costs, ensures that the repaired documents have a uniform format and consistent numbering, and enhances the professionalism and maintainability of the documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120893402B_ABST
    Figure CN120893402B_ABST
Patent Text Reader

Abstract

The application provides a document directory error repair method and system based on multi-model cooperation, comprising constructing a document into a graph structure, each paragraph as a node and extracting semantic, format and position features; using a three-layer graph convolutional neural network to process the graph structure to obtain a node representation fused with global information; screening nodes with confidence exceeding a threshold as candidate titles; extracting text and visual features of the candidate titles; performing two-class discrimination on the filtered candidates to form a real title set; detecting title errors and constructing an input sequence containing context, using an adaptive sliding window to process a long document; generating multiple candidates, scoring and selecting the best; matching new and old titles; and minimizing format consistency and serial number continuity cost. The application can accurately identify the title through its structural features in the graph even if the format of the title is not standard or lacks obvious markers, greatly improving the recall rate and accuracy of title identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of natural language processing and document processing technology, specifically to a method and system for document directory error repair based on multi-model collaboration. Background Technology

[0002] With the growing trend of AI-powered digital office and document processing, Markdown format files are becoming increasingly widely used due to their concise syntax and efficient formatting capabilities. However, table of contents errors frequently occur and are difficult to resolve during the editing, conversion, or generation of Markdown files. Currently, most processing methods still rely on manual checking and modification, which is not only inefficient but also prone to oversights. Existing technologies have several significant shortcomings in handling table of contents errors: First, in terms of title recognition, the lack of precise semantic analysis and format judgment mechanisms often makes it difficult to accurately distinguish between normal paragraphs and headings, resulting in many normal paragraphs being misidentified as headings. Second, existing methods are prone to missing normal headings with non-standard formats, missing numbers, or special symbols. Third, in complex document structures, table and image titles are often incorrectly identified as headings. Fourth, traditional methods are helpless in dealing with common complex situations in practical applications, such as the lack of clear standards for whether subheadings should be included in the table of contents, summary sentences being easily misidentified as headings due to their concise content, excessively deep heading levels disrupting contextual coherence, and weak semantic and format connections between headings and body text. These problems not only significantly increase the manual cost of document processing and reduce work efficiency, but also seriously affect the accuracy and standardization of Markdown file tables of contents. This results in extremely poor readability and maintainability of documents during subsequent editing, retrieval, and reading, greatly limiting the efficient application of Markdown files in the field of document processing. Therefore, there is an urgent need for an innovative solution that can comprehensively, accurately, and efficiently repair Markdown table of contents errors. Summary of the Invention

[0003] To overcome the shortcomings of existing technologies, this invention proposes a document directory error repair method and system based on multi-model collaboration, providing a complete end-to-end solution. From candidate title extraction, multi-level filtering, and intelligent discrimination to error detection, automatic correction, and global optimization, a complete processing flow is formed. The system generates detailed processing logs and confidence assessments, allowing users to understand the basis for each modification and perform manual review and adjustments when necessary. This transparent approach enhances user trust in the system and facilitates deployment in real-world production environments.

[0004] To achieve the above objectives, this invention proposes a Markdown document table of contents error repair method based on multi-model collaboration, comprising the following steps:

[0005] Step 1: Convert the Markdown document to be processed into a graph structure representation, where each paragraph in the document is a node in the graph, and construct a feature vector for each node;

[0006] The feature vector consists of three parts: a semantic embedding vector obtained by encoding the paragraph text through a pre-trained language model, a format feature vector obtained by extracting paragraph format information, and a position encoding vector representing the position of the paragraph in the document;

[0007] Edge connections are established between nodes. The weight of the edge consists of two weighted parts: the first part is the semantic similarity between the two paragraphs multiplied by a learnable weight coefficient, and the second part is an exponential decay function based on the distance between paragraph positions multiplied by another learnable weight coefficient. The decay rate of the exponential decay function is controlled by a temperature parameter.

[0008] Step 2: Use a three-layer graph convolutional neural network to process the graph structure constructed in Step 1, with each layer employing a different information aggregation strategy;

[0009] The first layer uses mean aggregation to capture local features, the second layer uses attention-weighted aggregation to capture important neighbor information, and the third layer uses maximum aggregation to extract significant features. Information is propagated between adjacent nodes through edge weight normalization. Residual connections and layer normalization are added between each layer. After passing through three layers, a node representation that integrates the global structure information of the document is obtained.

[0010] Step 3: Combine the node representations and regular expression matching results obtained in Step 2 to filter candidate titles;

[0011] Regular expressions are used to match common heading format patterns, including numbered sequences, Chinese numbering, Markdown heading symbols, and uppercase letter numbers.

[0012] The confidence score in the node representation is merged with the regular expression matching result to filter out nodes with a confidence score exceeding a preset threshold as a candidate title set;

[0013] Step 4: Extract both textual and visual features from each candidate title obtained in Step 3.

[0014] Text features are obtained through language model encoding, while visual features are extracted by analyzing the layout information after Markdown rendering, including visual attributes such as font size, bolding, and indentation.

[0015] The two features are fused using a multi-head cross-attention mechanism. Specifically, the text features are used as the query vector, and the visual features are used as the key vector and value vector. The enhanced representation of the text features by the visual features is obtained through attention calculation, and the original text information is preserved through residual connection.

[0016] Filtering is performed based on the fused features and a preset rule set, which includes special punctuation density detection, table position judgment, paragraph length constraint, and keyword filtering.

[0017] Step 5: Input the candidate titles filtered in Step 4 into the large language model that has been fine-tuned by contrastive learning. The model is trained using more than 10,000 labeled documents. During training, structured prompts are used to guide the model to understand the task. The prompts include task description, judgment criteria and output format requirements.

[0018] The model performs binary classification on each candidate title, outputs the judgment result of whether it is a real title, and forms a title set of candidates that are judged as real titles;

[0019] Step 6: Perform error detection on the title set obtained in Step 5 to identify titles with missing serial numbers, duplicate serial numbers, serial number jumps, inconsistent formats, or incorrect hierarchical relationships.

[0020] For a title containing errors, construct an input sequence that includes left and right context information;

[0021] When a document is too long and exceeds the model's processing capacity, an adaptive sliding window mechanism is used. The window size is dynamically calculated based on the average paragraph length of the document and is set to 2 to 5 times the average length.

[0022] Two overlapping areas of paragraphs are retained between adjacent windows, and the processing results of the overlapping areas are verified for bidirectional semantic consistency.

[0023] Step 7: Input the input sequence constructed in Step 6 into the sequence generation model for title correction. During the generation process, maintain the title level constraint mechanism to ensure that the depth of the generated title level will not exceed one level of the previous title level to prevent level jumps.

[0024] Five candidate correction results are generated for each erroneous title. The best result is selected by comprehensive scoring. The scoring includes the generation probability score given by the language model and the structural rationality score based on the format specification. The structural rationality is evaluated from three dimensions: consistency of serial number format, rationality of hierarchical relationship and appropriateness of title length.

[0025] Step 8: Match the corrected title obtained in Step 7 with the title in the original document. The matching process uses a weighted combination of three similarities: 30% for edit distance similarity, 50% for semantic similarity, and 20% for positional similarity. Positional similarity is obtained by calculating the exponential decay of the position difference between the old and new titles. The decay parameter is adaptively set according to the average interval between adjacent titles in the document. When the positional offset exceeds the maximum allowed value of 5 paragraphs, an additional penalty mechanism is applied to reduce the probability of matching.

[0026] Only title pairs with a combined similarity exceeding the threshold will be replaced.

[0027] Step 9: Perform global optimization on the title sequence that was replaced in Step 8, construct an optimization objective function, and minimize the format consistency cost and the sequence number continuity cost. The format consistency cost includes deviations of the sequence number format from the mainstream format, inconsistencies between the level markers and the actual level, and mismatches between indentation and level. The sequence number continuity cost measures the rationality of the sequence numbers of adjacent title numbers at the same level.

[0028] The optimal title numbering scheme is solved using dynamic programming to ensure that the final output title sequence has a consistent format and continuous numbering.

[0029] Furthermore, the graph structure construction in step 1 is specifically implemented as follows: each paragraph is encoded using a pre-trained BERT model to obtain a 768-dimensional semantic vector; the format feature vector contains 50 dimensions, recording whether it contains format information such as numeric serial numbers, Chinese serial numbers, Markdown symbols, serial number type, and indentation level; the position encoding is generated using a sine coding method; the three vectors are concatenated and mapped to a 256-dimensional unified feature space through a fully connected layer; the two learnable coefficients of the edge weights are initialized to 0.5 and optimized through backpropagation during training.

[0030] Furthermore, the regular expression matching patterns in step 3 include: matching patterns that begin with Arabic numerals followed by periods, matching patterns that match numbers within parentheses, matching patterns that match Chinese numerals followed by commas, matching Markdown heading patterns that begin with 1 to 6 hash symbols, matching patterns that match uppercase letters followed by periods, and matching patterns that match Roman numerals. For paragraphs without obvious formatting features, their semantic relevance to the identified headings and their structural position in the document are analyzed to determine whether they are potential headings.

[0031] Furthermore, the visual feature extraction in step 4 is achieved by parsing the Markdown rendering results. The extracted features include: the ratio of font size to body text, whether bold style is used, number of indentation levels, whether it is a separate paragraph, and number of blank lines before and after the paragraph. The multi-head cross-attention mechanism uses 8 attention heads, each with a dimension of 64, to capture the diverse associations between text and visual features by computing different attention modes in parallel.

[0032] Furthermore, the rule filtering in step 4 specifically includes: calculating the ratio of the total number of periods, question marks, exclamation marks, and semicolons in a paragraph to the paragraph length; if the ratio exceeds 0.1, it is excluded; determining whether a paragraph is located inside a table by detecting vertical lines and consecutive minus signs; if so, it is excluded; setting the paragraph length to be between 5 and 100 characters; and calculating the density of non-heading keywords in the paragraph, including conjunctions such as "but," "therefore," and "for example," and excluding paragraphs with a density exceeding a threshold.

[0033] Furthermore, the error detection methods in step 6 include: detecting sequence number jumps and repetitions by checking the continuity of sequence number values; detecting inconsistent formats by checking the consistency of format patterns; detecting hierarchical jumps by checking the progressive relationship of hierarchical depth; and using a voting mechanism to handle the overlapping area of ​​the adaptive window. When the processing results of the front and back windows are inconsistent, the result with higher confidence is selected. If the confidence is similar, the overlapping area is expanded and reprocessed.

[0034] Furthermore, the hierarchical constraints in step 7 are implemented by maintaining a hierarchical stack: when processing each title, search downwards from the top of the stack for the first title whose level is less than or equal to the current title as the parent node; pop all titles above the parent node from the stack, and then push the current title onto the stack; the generated title must maintain semantic relevance with the parent node in the stack, and the relevance is determined by calculating the cosine similarity of their semantic vectors.

[0035] Furthermore, the positional similarity calculation in step 8 takes into account document characteristics: for technical documents with dense headings, the positional sensitivity parameter is set to a smaller value, allowing for smaller positional deviations; for narrative documents with sparse headings, the positional sensitivity parameter is set to a larger value, allowing for larger positional deviations; the specific value of the parameter is obtained by statistically analyzing the average interval between adjacent headings and dividing by 2, ensuring that it is within a reasonable range of 10 to 20.

[0036] Furthermore, it also includes incremental processing optimization: when the document is only partially modified, the modification location is identified and the subgraph is reconstructed only for the range of 10 paragraphs before and after; the boundary nodes of the subgraph and the original graph are kept connected, and the modification is judged to affect a larger range by comparing the feature vector changes of the boundary nodes; if the feature changes of the boundary nodes exceed the threshold, the processing range is expanded until it stabilizes.

[0037] A Markdown document table of contents error repair system based on multi-model collaboration, applicable to the above-mentioned methods, includes: a document parsing module for reading Markdown files, parsing the document structure, and extracting all paragraph content, formatting tags, and position information;

[0038] The graph construction module converts the parsed paragraph information into a graph structure, calculates the semantic similarity and positional relationship between paragraphs, and generates weighted edge connections.

[0039] The graph neural network module contains three graph convolutional layers with different aggregation strategies to achieve multi-hop propagation of document structure information and global feature learning;

[0040] The candidate extraction module integrates the output of the graph neural network and the results of regular expression matching to generate a list of candidate titles.

[0041] The multimodal fusion module extracts text semantic features and visual typography features in parallel, and achieves feature fusion through a cross-attention mechanism;

[0042] The rule-based filtering module filters candidate titles based on preset rules such as punctuation density, table position, length range, and keywords.

[0043] The title discrimination module calls a finely tuned large language model to determine the authenticity of filtered candidates.

[0044] The error detection module analyzes various error patterns in the title sequence and marks the titles that need to be corrected;

[0045] The sequence generation module generates multiple correction candidates under hierarchical constraints and selects the optimal result through comprehensive scoring.

[0046] The similarity matching module calculates a weighted combination of three similarities: edit distance, semantic similarity, and positional similarity, to achieve accurate matching between new and old titles;

[0047] The global optimization module uses a dynamic programming algorithm to optimize the format consistency and numbering continuity of the overall title sequence.

[0048] The output module generates the corrected Markdown document and records all modification operations to form a traceable processing log.

[0049] Compared with the prior art, the beneficial effects of the present invention are:

[0050] 1. This invention provides a document table of contents error repair method and system based on multi-model collaboration, completely eliminating the inefficient traditional manual inspection and modification mode. Through automated title identification and table of contents correction processes, it achieves rapid repair of Markdown table of contents errors. When processing large-scale documents, the table of contents repair time can be shortened from hours or even days of manual processing to minutes, greatly improving document processing efficiency, significantly reducing labor costs, and saving enterprises and individual users a lot of time and resources.

[0051] 2. This invention provides a document directory error repair method and system based on multi-model collaboration. By modeling the tree structure of documents using GCN, it captures the hierarchical relationships and global dependencies between headings, significantly improving the accuracy of complex document heading recognition, which is superior to traditional methods based on regular expressions or single semantic analysis.

[0052] 3. This invention provides a document directory error repair method and system based on multi-model collaboration. By constructing the document as a graph structure and processing it using a graph neural network, this invention can capture the global structural information of the document and the complex relationships between paragraphs, breaking through the limitations of traditional methods that rely solely on local features. This graph structure representation enables the system to understand the hierarchical relationship and structural importance of headings in the document. Even for headings with irregular formats or lacking clear markings, it can accurately identify them through their structural features in the graph, significantly improving the recall and accuracy of heading recognition.

[0053] 4. This invention provides a document directory error repair method and system based on multi-model collaboration. Employing a sequence generation model combined with a hierarchical constraint mechanism, it can intelligently correct various directory errors. The system can handle not only simple number completion but also complex issues such as format unification, hierarchical adjustment, and number rearrangement. By maintaining a title hierarchy stack and semantic relevance constraints, it ensures that the corrected titles conform to format specifications while maintaining good semantic coherence and hierarchical rationality. Compared to manual repair, the processing efficiency is improved by tens of times, and the repair quality is more stable and reliable.

[0054] 5. This invention provides a document directory error repair method and system based on multi-model collaboration. By using a dynamic programming algorithm to simultaneously optimize format consistency and numbering continuity, it avoids global inconsistencies that may result from local corrections. The repaired document not only has correct headings, but also a clear overall directory structure, unified format, and consistent numbering, significantly improving the document's professionalism and maintainability. Attached Figure Description

[0055] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0056] Figure 1 This is a schematic diagram of the system flow of the present invention. Detailed Implementation

[0057] The technical solution of the present invention will be more clearly and completely explained below with reference to the accompanying drawings and through the description of preferred embodiments of the present invention.

[0058] like Figure 1 As shown, the present invention is:

[0059] Step 1: Construct the Markdown document into a graph structure, with each paragraph as a node and extract semantic, format, and positional features. The edge weights between nodes are determined by a weighted combination of semantic similarity and positional distance.

[0060] Step 2: Use a three-layer graph convolutional neural network to process the graph structure. Each layer adopts the mean aggregation, attention aggregation and maximum value aggregation strategies to obtain node representations that integrate global information.

[0061] Step 3: Combine the graph neural network output and the regular expression matching results to filter nodes with confidence scores exceeding the threshold as candidate titles;

[0062] Step 4: Extract the textual and visual features of the candidate titles, fuse them through a multi-head cross-attention mechanism, and filter them based on a rule set;

[0063] Step 5: Use a fine-tuned large language model to perform binary classification on the filtered candidates to form a set of real titles;

[0064] Step 6: Detect title errors and construct an input sequence containing context, using an adaptive sliding window for long documents;

[0065] Step 7: Correct erroneous titles under hierarchical constraints using a sequence generation model, generate multiple candidates, score and select the best one;

[0066] Step 8: Match new and old titles based on a weighted combination of edit distance, semantics, and positional similarity, and apply a penalty when the positional offset is too large;

[0067] Step 9: Use a dynamic programming algorithm to globally optimize the title sequence, minimizing the cost of format consistency and sequence number continuity.

[0068] As one specific implementation method, the present invention will be described in detail below with reference to specific embodiments:

[0069] Graph Structure Modeling and Candidate Title Extraction: When processing a Markdown document containing 200 paragraphs, the system initiates a regular expression matching process. For example, for the paragraph "1. Chapter 1 System Overview", the system uses a combination of regular expressions and the GCN network to identify "1." and the Chinese numerical sequence "Chapter 1", quickly extracting it as a candidate title. For the paragraph "#System Functional Modules", it is included in the candidate title range based on the Markdown title symbol "#". After completing the first round of regular expression matching, a total of 50 candidate titles are extracted. For paragraphs without serial numbers, such as "System Core Algorithm Design", the system initiates a supplementary extraction process based on semantic analysis. By analyzing the semantic relationship between the paragraph and the preceding and following paragraphs, the keyword distribution, and the position in the document, it determines that the paragraph is a potential title and adds it to the candidate title list.

[0070] Rule-based filtering and multimodal fusion: Rule-based filtering was applied to the 50 extracted candidate titles. First, the number of special punctuation marks was checked. For example, the paragraph "This system mainly includes a data acquisition module, a data processing module, and a result output module." contained two commas, exceeding the threshold for special punctuation marks set by the rule, and was therefore excluded. Next, using QWEN2.5-VL, the paragraph's formatting characteristics (such as bolding or indentation) were analyzed to exclude paragraphs that did not conform to the visual specifications for titles. Finally, through the fusion of rules and multimodal technology, it was determined whether the paragraph was located inside a table. If it was, the paragraph was likely related to the table and not part of the document's headings or table of contents, and was also excluded. After this filtering process, the remaining 35 candidate titles proceeded to the next step.

[0071] Model discrimination: The 35 candidate titles, filtered according to rules, were input into a large model that had been fine-tuned based on prompt word engineering. For example, for the candidate title "System Installation Steps Instructions," the model judged it to be a real title based on the prompt word requirements and the title features it had learned; while for the candidate title "During the system installation process, the first thing to do is prepare the installation environment.", the model judged it to be a normal paragraph and excluded it. Ultimately, the model selected 28 real document titles.

[0072] Model Correction: Suppose that after title identification, an incorrect title "2. Chapter Two System Design Scheme" is found, whose numbering does not match the actual chapter order; it should be "3. Chapter Two System Design Scheme". This incorrect title is input into the sequence generation model. Based on the numbering logic and contextual relationships learned during training, combined with the prompt "Please correct the following title numbering error based on the overall document structure and semantic coherence: 2. Chapter Two System Design Scheme", the model generates the correct title "3. Chapter Two System Design Scheme". For a long table of contents containing 50 titles, the sliding window size is set to 10, and the overlap area is 2. The table of contents is segmented into windows and input into the model for generation, ensuring that the model can stably and accurately process long table of contents data.

[0073] The 28 corrected headings were then subjected to fuzzy matching with the headings in the original Markdown file. Edit distance was used to calculate heading similarity, with a matching threshold of 0.85. For example, the corrected heading "3. Chapter Two System Design Scheme" had an edit distance similarity of 0.9 with the incorrect heading "2. Chapter Two System Design Scheme" in the original file, which was above the threshold. The system automatically replaced the incorrect heading with the correct one. After all heading replacements were completed, a final, accurate Markdown table of contents was generated. Users could use the system's viewing function to compare the original and corrected table of contents to confirm the repair effect.

[0074] As a specific implementation method, the specific implementation process of the present invention will be described in detail using a Markdown file containing technical documentation as an example. Assume the Markdown document to be processed is a software system design document containing approximately 300 paragraphs, which contains various table of contents errors, such as missing heading numbers, inconsistent numbering formats, and normal paragraphs being misidentified as headings.

[0075] The system first reads the Markdown document and parses it into a list of paragraphs. For example, the document contains paragraphs such as "1. System Overview", "The system mainly includes three modules", "2.1 Data Acquisition Module", and "### Data Processing Flow". During the parsing process, the system records the original text content of each paragraph, its position index in the document, and the formatting tags it contains.

[0076] Next, a graph representation of the document is constructed. The system treats each paragraph as a graph node; for example, "1. System Overview" is node 1, and "The system mainly includes three modules" is node 2. For each node, the system uses a pre-trained BERT model to encode the paragraph text, resulting in a 768-dimensional semantic vector. Simultaneously, format features are extracted, such as node 1 containing the number "1." and node 4 containing Markdown heading symbols "###". The format feature vector records 50 dimensions of information, including whether various numbers, heading symbols, and indentation levels are present. Positional encoding is generated using a sine function based on the paragraph's position in the document. After concatenating the three feature vectors, they are mapped to a 256-dimensional unified feature space through a fully connected neural network layer.

[0077] When establishing edge connections between nodes, the system calculates the semantic similarity between each pair of paragraphs. For example, "system overview" and "the system mainly includes three modules" have high semantic similarity because they both involve system-related content. Positional distance is also considered; adjacent paragraphs have a positional distance of 1, which carries a higher weight; nodes separated by 10 paragraphs have significantly reduced positional weight. The edge weight is obtained by weighting semantic similarity and positional relationship, with the initial weight coefficient set to 0.5, and subsequently optimized through training.

[0078] After constructing the graph structure, a three-layer graph convolutional neural network is used for processing. The first layer uses mean aggregation, where each node's new feature is a combination of its own feature and the mean of all its neighbors' features, thus capturing local contextual information. The second layer uses an attention mechanism, assigning different weights to different neighbors, with important neighbor nodes contributing more. The third layer uses maximum aggregation to extract the most salient features within the neighborhood. Residual connections exist between each layer, meaning new features are added to existing features to prevent information loss. After these three layers, each node incorporates the global structural information of the document.

[0079] Based on the output of the graph neural network, candidate titles are filtered using regular expression matching. The system uses multiple regular expression patterns, such as matching "number + period" to identify "1. System Overview", and matching "###" to identify "### Data Processing Flow". For paragraphs like "System Architecture Design" that lack obvious formatting features, the system analyzes their importance score in the graph structure and their relevance to already identified titles to determine if they are likely missing formatting elements. By fusing the confidence score of the graph neural network with the regular expression matching results, approximately 50 candidate titles are selected.

[0080] Multimodal feature extraction and fusion are performed on each candidate title. Text features are obtained through language model encoding, capturing the semantic information of the title. Visual features are extracted by analyzing Markdown rendering effects; for example, "# First-level heading" is rendered with a larger and bolder font, while "## Second-level heading" has a slightly smaller font. The system records visual attributes such as relative font size, bolding, indentation levels, and the number of preceding and following blank lines. A cross-attention mechanism with eight attention heads is used to allow text features to query relevant information in visual features. For example, text features that semantically represent "chapter start" will focus on visual features such as "larger font" and "separate paragraph". The fused features retain semantic information while enhancing the ability to discriminate formatting-related information.

[0081] Filtering is performed based on fused features and rule sets. The system checks the candidate title "This module is mainly responsible for data collection, cleaning, and preprocessing." and finds that it contains two commas and a period, with a special punctuation density exceeding the threshold of 0.1, so it is excluded. For "functional modules" located in tables, the presence of "|" symbols and "---" separators before and after indicates that it is inside a table, so it is also excluded. Candidates with paragraphs that are too short (e.g., only the word "Overview") or too long (detailed descriptions exceeding 100 words) are also filtered. Paragraphs containing conjunctions such as "but" and "therefore" are judged as normal narration rather than titles. After rule filtering, the number of candidate titles is reduced to 35.

[0082] The filtered candidate inputs were then fine-tuned into a large language model for discrimination. The model, trained on over 10,000 annotated documents, learned to recognize patterns in real titles. For the candidate "2.1 Data Acquisition Module," the model analyzed its formatting (hierarchical numbering), semantic features (general description), and contextual relationship (preceded by "2. System Module"), classifying it as a real title. For "In practical applications, data acquisition is the first step," although its position is important, its semantics are specific rather than general, and it was judged not as a title. Ultimately, 28 real titles were identified.

[0083] Error detection is performed on the identified titles. The system found that "2.1 Data Acquisition Module" is followed directly by "2.3 Data Storage Module," indicating a jump in sequence number; the Chinese sequence number format of "Chapter 3 System Implementation" is inconsistent with other numerical sequence numbers; and some titles are missing sequence marks. For excessively long documents, the system calculates the average paragraph length to be 50 characters and sets the sliding window size to 150 characters (3 times the average length). The document is divided into multiple overlapping windows for processing, with adjacent windows retaining an overlap of two paragraphs. When the processing results for the overlapping area are inconsistent between two windows, the semantic coherence and structural rationality of the two results are compared, and the result with the higher score is selected.

[0084] A sequence generation model was used to correct erroneous headings. For the heading "Data Processing Flow" which lacked a sequence number, the model analyzed that it was preceded by "2.1" and followed by "2.3", generating "2.2 Data Processing Flow". During the generation process, the system maintained hierarchical constraints to ensure that it did not jump directly from a first-level heading to a third-level heading. Five candidate corrections were generated for each erroneous heading, such as "2.2 Data Processing Flow", "2.2 Data Processing Module", and "2.2. Data Processing Flow". A scoring mechanism was used, considering the generation probability of the language model (the naturalness of the expression) and the structural rationality (whether the sequence number format is consistent with the context, whether the hierarchy is reasonable, and whether the length is appropriate), and the correction with the highest score was selected.

[0085] The system matches the corrected title with the original document. It calculates an edit distance similarity of 0.7 (only the sequence number is added) between "2.2 Data Processing Flow" and the original "Data Processing Flow," a semantic similarity of 1.0 (text content is identical), and a positional similarity of 1.0 based on their identical positions within the document. These three similarities are weighted at 0.3, 0.5, and 0.2 respectively, resulting in a combined similarity of 0.85, exceeding the threshold, and a replacement is executed. For cases with significant positional offsets, such as a title being incorrectly moved more than 10 paragraphs away, the system applies a penalty, reducing the likelihood of a match.

[0086] After replacing all headings, a global optimization was performed. System checks revealed inconsistencies: some headings used "1." format, while others used "1、" format. Regarding numbering, "2.1" and "2.2" were followed directly by "2.5," causing a continuity issue. The system then formulated optimization goals, considering both format consistency and numbering continuity. A dynamic programming algorithm was used to find the optimal numbering scheme for each heading. For example, all first-level headings were standardized to "1." format, and second-level headings to "1.1" format; the abrupt "2.5" was corrected to "2.3". The final output was a sequence of headings with consistent formatting and numbering.

[0087] Throughout the processing, the system supports incremental updates. When a user modifies only a section of a document, the system identifies the modified location and reconstructs the subgraph only for the 10 paragraphs before and after that location. By comparing the characteristic changes of the subgraph boundary nodes, it determines whether the modification will affect a wider area. If the characteristic changes of the boundary nodes are significant, it indicates that the modification has had a large impact, and the system will expand the processing range until the boundaries stabilize.

[0088] Finally, the system generates a corrected Markdown document with all headings formatted correctly, numbered correctly, and with a clear hierarchy. It also generates a detailed processing log, recording each modification, including the original content, the corrected content, the reason for the modification, and the confidence level. Modifications with a confidence level below 0.7 are specifically marked and recommended for manual review. Users can view the log to understand the system's processing logic and make manual interventions and adjustments when necessary. Through this multi-model collaborative approach, the system achieves automated and intelligent repair of Markdown document table of contents errors.

[0089] As a specific implementation method, a Markdown document table of contents error repair method based on multi-model collaboration includes the following steps:

[0090] The Markdown document to be processed is constructed as a directed graph structure G=(V,E), where V is the set of nodes, and each paragraph... As node v i Let E be the set of edges; construct a feature vector for each node containing semantic embedding, format features, and positional encoding; calculate the edge weights between node i and node j:

[0091] ;

[0092] Where α is the learnable weight coefficient of semantic similarity, and β is the learnable weight coefficient of positional distance. This is a semantic similarity function between paragraphs, with values ​​ranging from [0,1]. and These are the position indices of paragraphs i and j in the document, respectively. The temperature parameter controls the decay rate of the effect of location distance, with a value range of 5-10.

[0093] The edge weight parameter is obtained through gradient descent optimization, maximizing the edge weight between correct heading nodes and minimizing the edge weight between non-heading nodes. The temperature parameter τ is adaptively adjusted according to document characteristics, with a smaller value set for densely packed technical documents and a larger value set for sparsely packed narrative documents.

[0094] Multi-layer graph convolutional neural networks are used to transmit and aggregate information in the constructed graph structure. Feature information is propagated between neighboring nodes through normalized edge weights. After passing through L layers, a node representation containing global structural information is obtained.

[0095] Based on the node representations and regular expression matching results obtained in step 2, filter the candidate title set C;

[0096] For each element in the candidate title set C, extract the text feature f_text and the visual layout feature f_visual, and use a multimodal cross-attention mechanism to calculate the fused feature:

[0097] ;

[0098] in The fused feature vector The text semantic feature vector serves as the query matrix Q; The visual feature vectors are represented by the key matrix K and the value matrix V; they are connected via residuals. "Preserve the original text information; filter based on fusion features and preset rules to obtain a candidate title set C';

[0099] Multimodal fusion is achieved through parallel processing: text features Obtained by encoding from a pre-trained language model; visual features By analyzing the text rendered by Markdown

[0100] Input the candidate title set C' into the fine-tuned large language model for binary classification and output the true title set T;

[0101] For erroneous titles in the title set T, construct an input sequence containing context, use an adaptive sliding window mechanism to handle ultra-long documents, and dynamically adjust the window size according to the average paragraph length of the document; perform bidirectional semantic consistency verification on overlapping areas;

[0102] The adaptive sliding window dynamically adjusts its size based on document complexity, with the window overlap area set to two paragraphs. When the consistency score of the processing result for the overlap area is lower than 0.8, the overlap area is expanded and the processing is repeated.

[0103] Errors in captions are corrected using a sequence generation model, while maintaining caption hierarchy constraints during the generation process.

[0104] ;

[0105] in This indicates the hierarchy depth of the i-th heading. The first title is the preceding title of the i-th title; this constraint ensures that the hierarchy of subsequent titles is at most one level deeper than the preceding title, preventing hierarchical jumps; the optimal result is selected from multiple candidate corrections through a scoring mechanism; K=5 candidate corrections are generated for each erroneous title, and the scoring mechanism comprehensively considers the generation probability of the language model and the structural rationality score, where structural rationality includes consistency of sequence format, rationality of hierarchical relationship, and appropriateness of title length.

[0106] Calculate the similarity between the corrected title and the original document title, where positional similarity is calculated as follows:

[0107] ;

[0108] in To correct the position index of the title. This is the position index of the original title. This is a position-sensitive parameter that controls the tolerance for positional differences, with a value between 10 and 20. When the positional offset exceeds the maximum threshold Δmax, a penalty factor is applied.

[0109] ;

[0110] Where Δmax is the maximum allowed position offset, set to 5 paragraphs, and μ is the penalty decay parameter; title matching and replacement are completed by combining multiple similarity indicators;

[0111] The overall similarity in step 8 is composed of a weighted average of edit distance similarity, semantic similarity, and positional similarity, with weights of 0.3, 0.5, and 0.2, respectively; position-sensitive parameters... Dynamically set based on the average interval between adjacent headings to ensure it is within the range of [10, 20];

[0112] Perform global optimization on the corrected title sequence, with the objective function being:

[0113] ;

[0114] in Title The cost of format consistency measures the degree of deviation from the standard format; For adjacent heading pairs The cost of sequence number continuity is used to measure the rationality of sequence number arrangement; the optimal sequence number allocation scheme is solved through dynamic programming algorithm;

[0115] Cost of format consistency It includes three dimensions: serial number format deviation, hierarchical tag mismatch, and indentation mismatch; serial number continuity cost Defined as the degree of deviation of the difference between adjacent same-level heading numbers from 1.

[0116] It also includes an incremental processing mechanism: for local modifications to the document, only the subgraph within the affected area is reconstructed, and the processing results of the unaffected areas are reused; the need to expand the processing range is determined by comparing the changes in the characteristics of the boundary nodes of the subgraph.

[0117] It also includes confidence assessment and grading: a confidence score is calculated for each title discrimination and correction result; those with a confidence score higher than 0.85 are automatically processed, those with a confidence score between 0.7 and 0.85 are marked as recommended for review, and those with a confidence score lower than 0.7 must be manually confirmed.

[0118] A Markdown document table of contents error repair system based on multi-model collaboration, comprising:

[0119] The document parsing module parses the Markdown document structure and extracts paragraph information;

[0120] The graph construction module, based on the formula... Construct a document graph structure;

[0121] The graph neural network module learns global structural features through multi-layer information transmission;

[0122] The multimodal fusion module implements the formula. Feature fusion;

[0123] The title discrimination module uses a finely tuned large language model for binary classification.

[0124] The sequence generation module, under hierarchical constraints Correct the error title below;

[0125] The similarity matching module uses location similarity. Achieving precise matching with the punishment mechanism;

[0126] Global optimization module, solving Obtain the optimal title sequence;

[0127] The results output module generates correction documents and processing reports.

[0128] The above-described specific embodiments are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Various modifications, substitutions, and improvements made by those skilled in the art to the technical solutions of the present invention based on the provided textual description and drawings, without departing from the design concept and spirit of the present invention, should all fall within the scope of protection of the present invention. The scope of protection of the present invention is determined by the claims.

Claims

1. A document directory error repair method based on multi-model collaboration, characterized in that, Includes the following steps: Step 1: Construct the Markdown document as a graph structure, with each paragraph as a node and extract semantic, formatting, and positional features. The edge weights between nodes are determined by a weighted combination of semantic similarity and positional distance; specifically as follows: The Markdown document to be processed is converted into a graph structure representation, with each paragraph in the document serving as a node in the graph, and a feature vector is constructed for each node. The feature vector consists of three parts: a semantic embedding vector obtained by encoding the paragraph text through a pre-trained language model, a format feature vector obtained by extracting paragraph format information, and a position encoding vector representing the position of the paragraph in the document; Edge connections are established between nodes. The weight of the edge consists of two weighted parts: the first part is the semantic similarity between the two paragraphs multiplied by a learnable weight coefficient, and the second part is an exponential decay function based on the distance between paragraph positions multiplied by another learnable weight coefficient. The decay rate of the exponential decay function is controlled by a temperature parameter. Step 2: Use a three-layer graph convolutional neural network to process the graph structure. Each layer adopts the mean aggregation, attention aggregation and maximum value aggregation strategies to obtain node representations that integrate global information. Step 3: Combine the graph neural network output and the regular expression matching results to filter nodes with confidence scores exceeding the threshold as candidate titles; Step 4: Extract the textual and visual features of the candidate titles, fuse them through a multi-head cross-attention mechanism, and filter them based on a rule set; Step 5: Use a fine-tuned large language model to perform binary classification on the filtered candidate titles to form a set of real titles; Step 6: Detect title errors and construct an input sequence containing context, using an adaptive sliding window for long documents; Step 7: Correct erroneous titles under hierarchical constraints using a sequence generation model, generate multiple candidate titles, and score and select the best one; Step 8: Match new and old titles based on a weighted combination of edit distance, semantics, and positional similarity, and apply a penalty when the positional offset is too large; Step 9: Use a dynamic programming algorithm to globally optimize the title sequence, minimizing the cost of format consistency and sequence number continuity.

2. The document directory error repair method based on multi-model collaboration as described in claim 1, characterized in that, Step 2 is as follows; A three-layer graph convolutional neural network is used to process the graph structure constructed in step 1, with each layer employing a different information aggregation strategy; The first layer uses mean aggregation to capture local features, the second layer uses attention-weighted aggregation to capture important neighbor information, and the third layer uses maximum aggregation to extract significant features. Information is propagated between adjacent nodes through edge weight normalization. Residual connections and layer normalization are added between each layer. After passing through three layers, a node representation that integrates the global structure information of the document is obtained. Step 3 is as follows: The candidate titles are filtered by combining the node representations obtained in step 2 and the regular expression matching results. Regular expressions are used to match common heading format patterns, including numbered sequences, Chinese numbering, Markdown heading symbols, and uppercase letter numbers; The confidence score in the node representation is merged with the regular expression matching result to filter out nodes with a confidence score exceeding a preset threshold as a candidate title set; Step 4 is as follows: For each candidate title obtained in step 3, both textual and visual features are extracted simultaneously. Text features are obtained through language model encoding, while visual features are extracted by analyzing the layout information after Markdown rendering, including visual attributes. The two features are fused using a multi-head cross-attention mechanism. Specifically, the text features are used as the query vector, and the visual features are used as the key vector and value vector. The enhanced representation of the text features by the visual features is obtained through attention calculation, and the original text information is preserved through residual connection. Filtering is performed based on the fused features and a preset rule set, which includes special punctuation density detection, table position judgment, paragraph length constraint, and keyword filtering.

3. The document directory error repair method based on multi-model collaboration as described in claim 1, characterized in that, Step 5 is as follows: The candidate titles filtered in step 4 are input into a large language model that has been fine-tuned through contrastive learning. The model is trained using more than 10,000 labeled documents. During training, structured cue words are used to guide the model to understand the task. The cue words include task description, judgment criteria and output format requirements. The model performs binary classification on each candidate title, outputs the judgment result of whether it is a real title, and forms a title set of candidate titles that are judged as real titles; Step 6 is as follows: Error detection is performed on the title set obtained in step 5 to identify titles with missing serial numbers, duplicate serial numbers, serial number jumps, inconsistent formats, or incorrect hierarchical relationships. For a title containing errors, construct an input sequence that includes left and right context information; When a document is too long and exceeds the model's processing capacity, an adaptive sliding window mechanism is used. The window size is dynamically calculated based on the average paragraph length of the document and is set to 2 to 5 times the average length. Two overlapping areas of paragraphs are retained between adjacent windows, and the processing results of the overlapping areas are verified for bidirectional semantic consistency.

4. The document directory error repair method based on multi-model collaboration as described in claim 1, characterized in that, Step 7 is as follows: The input sequence constructed in step 6 is input into the sequence generation model for title correction. During the generation process, a title level constraint mechanism is maintained to ensure that the depth of the generated title level does not exceed one level of the previous title level, thus preventing level jumps. Five candidate title correction results are generated for each erroneous title. The best result is selected by comprehensive scoring. The scoring includes the generation probability score given by the language model and the structural rationality score based on the format specification. The structural rationality is evaluated from three dimensions: consistency of serial number format, rationality of hierarchical relationship and appropriate title length. Step 8 is as follows: The corrected title obtained in step 7 is matched with the title in the original document. The matching process uses a weighted combination of three similarities: edit distance similarity (30%), semantic similarity (50%), and positional similarity (20%). Positional similarity is obtained by calculating the exponential decay of the positional difference between the old and new headings. The decay parameter is adaptively set according to the average interval between adjacent headings in the document. When the positional offset exceeds the maximum allowed value of 5 paragraphs, an additional penalty mechanism is applied to reduce the probability of matching. Only title pairs with a combined similarity exceeding the threshold will be replaced. Step 9 is as follows: The title sequence that has been replaced in step 8 is globally optimized to construct an optimization objective function, while minimizing the format consistency cost and the sequence number continuity cost. The format consistency cost includes deviations of the sequence number format from the mainstream format, discrepancies between the level markers and the actual level, and mismatches between indentation and level. The cost of numbering continuity measures the rationality of numbering adjacent headings at the same level; The optimal title numbering scheme is solved using dynamic programming to ensure that the final output title sequence has a consistent format and continuous numbering.

5. The document directory error repair method based on multi-model collaboration according to claim 1, characterized in that, The graph structure construction in step 1 is specifically implemented by using a pre-trained BERT model to encode each paragraph to obtain a 768-dimensional semantic embedding vector; The format feature vector contains 50 dimensions, recording whether it contains format information; the position encoding vector is generated using a sinusoidal encoding method; the three vectors are concatenated and mapped to a 256-dimensional unified feature space through a fully connected layer; the two learnable coefficients of the edge weights are initialized to 0.5 and optimized through backpropagation during training.

6. The document directory error repair method based on multi-model collaboration according to claim 1, characterized in that, The regular expression matching patterns in step 3 include: matching patterns that begin with Arabic numerals followed by periods, matching patterns that match numbers within parentheses, matching patterns that match Chinese numerals followed by commas, matching Markdown heading patterns that begin with 1 to 6 hash symbols, matching patterns that match uppercase letters followed by periods, and matching patterns that match Roman numerals. For paragraphs without obvious formatting features, their semantic relevance to the identified headings and their structural position in the document are analyzed to determine whether they are potential headings. The visual feature extraction in step 4 is achieved by parsing the Markdown rendering results. The extracted features include: the ratio of font size to body text, whether bold style is used, number of indentation levels, whether it is a separate paragraph, and the number of blank lines before and after the paragraph. The multi-head cross-attention mechanism uses 8 attention heads, each with a dimension of 64, to capture the diverse associations between text and visual features by computing different attention modes in parallel. The rule filtering in step 4 specifically includes: calculating the ratio of the total number of periods, question marks, exclamation marks, and semicolons in a paragraph to the paragraph length; if the ratio exceeds 0.1, it is excluded; determining whether a paragraph is located inside a table by detecting vertical lines and consecutive minus signs; if so, it is excluded; setting the paragraph length to be between 5 and 100 characters; and calculating the density of non-heading keywords in the paragraph, including conjunctions; if the density exceeds the threshold, it is excluded. The error detection methods in step 6 include: detecting sequence number jumps and repetitions by checking the continuity of sequence number values; detecting inconsistent formats by checking the consistency of format patterns; detecting hierarchical jumps by checking the progressive relationship of hierarchical depth; and using a voting mechanism to handle the overlapping area of ​​the adaptive window. When the processing results of the front and back windows are inconsistent, the result with higher confidence is selected. If the confidence is similar, the overlapping area is expanded and reprocessed.

7. The document directory error repair method based on multi-model collaboration according to claim 1, characterized in that, The hierarchical constraints in step 7 are implemented by maintaining a hierarchical stack: when processing each title, search down from the top of the stack for the first title whose level is less than or equal to the current title as the parent node; pop all titles above the parent node from the stack, and then push the current title onto the stack; the generated title must maintain semantic relevance with the parent node in the stack, and the relevance is determined by calculating the cosine similarity of the semantic embedding vectors of the two. The positional similarity calculation in step 8 takes into account document characteristics: for technical documents with dense headings, the positional sensitivity parameter is set less than that for narrative documents with sparse headings, and the allowed positional deviation for technical documents with dense headings is less than that for narrative documents with sparse headings; the specific value of the parameter is obtained by statistically analyzing the average interval between adjacent headings and dividing it by 2, ensuring that it is within a reasonable range of 10 to 20.

8. A document directory error repair system based on multi-model collaboration, applicable to the document directory error repair method based on multi-model collaboration as described in any one of claims 1-7, characterized in that, include: The document parsing module is used to read Markdown files, parse the document structure, and extract all paragraph content, formatting tags, and position information. The graph construction module converts the parsed paragraph information into a graph structure, calculates the semantic similarity and positional relationship between paragraphs, and generates weighted edge connections. The graph neural network module contains three graph convolutional layers with different aggregation strategies to achieve multi-hop propagation of document structure information and global feature learning; The candidate extraction module integrates the output of the graph neural network and the results of regular expression matching to generate a list of candidate titles. The multimodal fusion module extracts text semantic features and visual typography features in parallel, and achieves feature fusion through a cross-attention mechanism; The rule filtering module filters candidate titles based on preset rules; The title discrimination module calls the fine-tuned large language model to determine the authenticity of the filtered candidate titles. The error detection module analyzes various error patterns in the title sequence and marks the titles that need to be corrected; The sequence generation module generates multiple revised candidate titles under hierarchical constraints, and selects the optimal result through comprehensive scoring; The similarity matching module calculates a weighted combination of three similarities: edit distance, semantic similarity, and positional similarity, to achieve accurate matching between new and old titles; The global optimization module uses a dynamic programming algorithm to optimize the format consistency and numbering continuity of the overall title sequence. The output module generates the corrected Markdown document and records all modification operations to form a traceable processing log.

Citation Information

Patent Citations

  • Method and system for intelligently generating document directory based on fused visual information

    CN115995087A

  • Knowledge graph and personalized learning path construction method and system

    CN117952200A