A method and computing device for structurally processing a document
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-30
- Publication Date
- 2026-08-11
AI Technical Summary
[0007]本发明实施例提供一种基于元数据与推理预算的文档结构恢复方法及系统,旨在解决现有技术在有限推理预算下,难以兼顾文档结构恢复质量与计算资源成本的技术问题
[0017] The solution provided in the embodiments of this specification determines the difficulty level of each document region based on the metadata features and confidence information corresponding to each document region, and determines the large model processing strategy for the document region based on the difficulty level. That is, the large model resources are scheduled based on difficulty awareness, which can significantly improve the structural recovery accuracy of complex documents under the same budget, or significantly reduce the computational cost under the same accuracy requirements.
Smart Images

Figure CN122547798A_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification belong to the field of intelligent document processing, and in particular relate to a method and computing device for structuring documents. Background Technology
[0002] As enterprises deepen their digital transformation, the demand for knowledge mining from massive amounts of unstructured or semi-structured documents (such as PDFs, scanned documents, and HTML web pages) is growing. To build an efficient knowledge base or retrieval-enhanced generation (RAG) system, the primary task is to restore the structure and segment the original documents. Structure restoration aims to reconstruct the document's logical hierarchy from a flat text flow, identifying heading levels, paragraph boundaries, and table relationships to form a tree-like skeleton. Segmentation, based on the restored structure, divides the document into semantically complete units for use by downstream tasks. This process typically relies on technologies such as optical character recognition (OCR), layout analysis, and large language models (LLM).
[0003] In existing document processing solutions, there are several typical strategies for structure recovery and segmentation. The first is the unified strategy model, which processes all areas of a document using a large language model with the same configuration. Regardless of whether the content is a well-formatted table of contents or a complex, disorganized table, the same model with the same computing power is used to execute the same parsing process. The second is the static rule switching model, which pre-sets processing strategies based on the document's macro-level attributes (such as file type, source system, or file size). Different documents may use different models, but the processing logic within a single document remains consistent. The third is the text content-based difficulty assessment model, which roughly judges the processing difficulty by analyzing pure text features such as text length and vocabulary complexity, and then allocates computing resources accordingly.
[0004] However, the aforementioned existing technologies often struggle to balance processing costs and structural recovery quality when dealing with large-scale, multi-format document processing scenarios. For a unified strategy model, while using a high-performance, large model throughout can handle complex scenarios well, it leads to significant waste of computational resources when processing large numbers of simple regions, resulting in high overall inference costs. Conversely, using a lightweight model or rule engine throughout can easily lead to problems such as misjudgment of heading levels and paragraph truncation errors when dealing with cross-page clauses, mixed layouts, or low-quality OCR results, resulting in decreased accuracy in structural recovery.
[0005] For static rule switching modes, due to their coarse-grained division, they cannot perceive fine-grained differences within a document. A document often contains both structurally simple and structurally complex areas. Static strategies cannot dynamically adjust within the document, leading to simple areas potentially consuming excessive resources while difficult areas receive insufficient computational support. Furthermore, solutions that judge difficulty solely based on text content ignore the crucial structural information contained in formatting metadata (such as font size, bolding, indentation, and HTML tags) and business metadata (such as clause numbers and account types). In many cases, the structural difficulties of a document are precisely reflected in layout anomalies or metadata conflicts. Relying solely on textual semantics is insufficient to accurately identify these "structurally difficult areas," easily leading to a misalignment between resource scheduling strategies and actual needs.
[0006] Due to the lack of refined perception of document region difficulty and a corresponding dynamic resource scheduling mechanism, existing technical solutions generally suffer from low computational resource utilization and insufficient robustness in structural recovery under complex scenarios when processing massive amounts of documents. Especially under the condition of limited inference budget (such as token limits, time windows, or computing power limits), how to effectively control the overall cost without sacrificing the parsing quality of key regions remains a pressing technical challenge in the field of intelligent document processing. Summary of the Invention
[0007] This invention provides a document structure recovery method and system based on metadata and inference budget, aiming to solve the technical problem that existing technologies struggle to balance document structure recovery quality and computational resource costs under limited inference budgets.
[0008] The first aspect of this specification provides a method for structuring documents, including:
[0009] Divide the document to be processed into multiple document regions;
[0010] Obtain metadata features and confidence information corresponding to each document region;
[0011] Based on the metadata features and confidence information corresponding to each document region, the difficulty level of each document region is determined.
[0012] Based on the global inference budget and the difficulty level of each document region, a corresponding level of large language model processing strategy is assigned to each document region.
[0013] According to the large language model processing strategy for all document regions, each document region is processed in a structured manner.
[0014] A second aspect of this specification provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method described in the first aspect.
[0015] A third aspect of this specification provides a computing device, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement the method described in the first aspect.
[0016] A fourth aspect of this specification provides a computer program product including a computer program / instructions that, when executed by a processor, implement the steps of the method described in the first aspect.
[0017] The solution provided in the embodiments of this specification determines the difficulty level of each document region based on the metadata features and confidence information corresponding to each document region, and determines the large model processing strategy for the document region based on the difficulty level. That is, the large model resources are scheduled based on difficulty awareness, which can significantly improve the structural recovery accuracy of complex documents under the same budget, or significantly reduce the computational cost under the same accuracy requirements. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments in this specification, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart illustrating the method for structuring documents in the embodiments of this specification;
[0020] Figure 2 This is a schematic diagram illustrating the process of obtaining confidence information of a document region in the embodiments of this specification;
[0021] Figure 3 This is a schematic diagram illustrating the process of determining the difficulty level of a document area in the embodiments of this specification;
[0022] Figure 4 This is a schematic diagram of the structure of the generated local skeleton tree in the embodiments of this specification;
[0023] Figure 5 This is a schematic diagram illustrating the process of merging local skeleton trees for global processing in the embodiments of this specification. Detailed Implementation
[0024] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0025] like Figure 1 As shown, this embodiment provides a method for structuring documents, the main process of which includes steps S110 to S150. This method can be executed by a computing device that processes documents.
[0026] In step S110, the document to be processed is divided into multiple document regions.
[0027] In real-world deployment environments, documents to be processed can include various formats, such as Portable Document Format (PDF), Hypertext Markup Language (HTML) files, text data generated after Optical Character Recognition (OCR) processing, or plain text streams. These raw data often manifest as continuous byte streams or discrete sets of pages at the physical storage level. The inherent logical hierarchy, semantic boundaries, and layout patterns within these documents are crucial for downstream knowledge retrieval or question-answering tasks. To effectively utilize the data contained within documents, it is necessary to obtain the semantic logical structure of the document.
[0028] To this end, the document to be processed is first divided into multiple document regions. For example, the document can be divided into regions based on page numbers, or the boundaries of the regions can be defined by natural chapter titles, paragraph blocks, or fixed line number ranges. Each document region serves as the basic unit for subsequent independent scheduling and processing, carrying the text content and its associated information within a local area. Through this regional division, the system breaks down the originally massive global processing task into several sub-tasks whose difficulty can be independently assessed and resources allocated, laying the foundation for the subsequent execution of differentiated strategies.
[0029] The granularity of region division can be weighed according to the actual business scenario. In one implementation, the document is first analyzed to identify the physical boundaries of the pages, and each page is taken as an initial document region. Then, explicit separators within the page are detected, such as large blank spaces, page breaks, or specific chapter heading styles. If obvious chapter transitions are found within a page, the page can be further subdivided into multiple sub-regions.
[0030] After obtaining the document region division results, a list of regions can be stored, recording metadata such as the start and end positions of each region and its corresponding page number. This information is used not only to locate text content but also to track processing progress and manage resource consumption.
[0031] In step S120: Obtain the metadata features and confidence information corresponding to each document region.
[0032] Metadata corresponding to each document primitive can be obtained by parsing the document. A document primitive is the smallest unit of processing in a document. In specific implementations, it can correspond to a line of text output by an OCR engine, a text block extracted by a PDF parser, or a leaf node in an HTML DOM tree.
[0033] Metadata features can include typographic features, markup language tags, and business fields. Typographic features reflect the visual attributes of text, such as font size, whether it is bold, whether it is italic, indentation distance, alignment, and line spacing.
[0034] For example, a document obtained through OCR processing includes the following information:
[0035] { "doc_id": "Annual Report", "source_type": "txt", "language": "zh", "parse_profile": { "mode_hint": "auto", "budget": { "unit": "tokens", "total":1200}}, "metadata": { "layout_default": { "font_size_unit": "pt", "unknown_font_size": null, "unknown_indent": null}, "html": { "has_dom": false, "dom_path_available": false}, "business_schema_hint": []}, "lines": [ { "line_id": "L0001", "text": "Dear colleagues:", "page_num": 1, "layout": { "font_size":16, "is_bold": true, "indent": 0, "alignment": "left"}}, { "line_id": "L0002", "text": "It is an honor to present the company's annual report here", "page_num": 1}, { "line_id": "L0003", "text": "I. Review of Work in 2007", "page_num": 1, "layout": { "font_size":18, "is_bold": true, "indent": 0}}
[0036] { "line_id": "L0004", "text": "…", "page_num": 1}, { "line_id": "L0005", "text": "(I) Comprehensive economic strength has reached a new level.", "page_num": 1, "layout": { "font_size": 15, "is_bold": true, "indent": 0}}, { "line_id": "L0006", "text": "…", "page_num": 1},
[0037] … { "line_id": "L0015", "text": "…", "page_num": 1}, { "line_id":"L0016", "text": "(II)New Area Opens a New Chapter.", "page_num": 1, "layout": { "font_size": 15, "is_bold": true, "indent": 0}}, { "line_id": "L0017", "text":"…", "page_num": 1},…
[0038] In the above text information, the layout characteristics of each line can be obtained as metadata features, for example, "layout": { "font_size": 16, "is_bold": true, "indent": 0, "alignment": "left"}. Among them, line L0002 does not provide specific layout characteristics, that is, it indicates that the line uses the default layout information "layout_default".
[0039] For example, in a Word document, you can extract the formatting information of each line from the document code, such as font size, whether it is bold, and whether it is indented.
[0040] Markup language tags originate from the source code structure of a document, such as in HTML. <h1> to< / h1> <h6>Label, Label, <h1>、 、 < / h1> Tags and their nesting paths, or node attributes in an XML document. In HTML or XML documents, each document primitive is nested within a specific tag level. The tag type (e.g., ...) of the current document primitive can be recorded by traversing the DOM tree. ), tag paths (such as html / body / div / table / tr / td), and key attributes (such as class, id, rowspan). This tag information provides structural semantics beyond visual appearance. For example, a text that visually appears to be an ordinary paragraph may have a different meaning if its parent tag is... (The header cell) should be considered part of the table rather than an independent paragraph in the logical structure.
[0041] Business fields are unique identifiers in documents specific to a particular domain, such as account type and currency in a bank statement, clause number in a legal contract, and expense type in an invoice. Business fields aim to capture implicit structural signals in industry-specific documents. Multiple pre-defined regular expression rules or Named Entity Recognition (NER) models can be used to detect specific patterns such as "Article X," "Party A / Party B," "Account Number," and "Currency Symbol." When such business fields are identified in document primitives based on these rules or models, corresponding semantic tags can be applied to the text. This feature extraction based on business logic effectively compensates for the shortcomings of pure typesetting features in complex scenarios, especially when dealing with scanned documents or documents with messy typesetting, where business fields often become key anchors for restoring structure.
[0042] In addition to static metadata features, the confidence level of each document primitive can also be obtained. Depending on the document type, one or more of the following methods can be used to obtain the confidence level of each document primitive:
[0043] (1) Obtain the structural probability of document primitives based on calculation rules or classifiers. The structural probability may include, for example, "the probability that the document primitive is a title" or "the probability that the document primitive and the context have a preset logical relationship".
[0044] (2) Calculate the confidence score based on the scores corresponding to the preset typesetting rules or text patterns;
[0045] (3) Determine the structural probability of document primitives using a small-scale large model;
[0046] (4) Character recognition confidence of each document primitive output by the OCR recognition model.
[0047] In this process, by employing a lightweight classifier (such as a pruned BERT classifier or a simple logistic regression model) to perform preliminary structural role prediction for each document primitive (e.g., whether it is a title, a table, or a list item), the probability value output by the classifier can be obtained. , (etc.) is used as the confidence score. The confidence score can be determined by matching the document's elements against layout rules. Taking a single line of text as an example, if a line of text perfectly matches a preset title numbering rule (such as "Chapter 1", "1.1"), a high rule confidence score is assigned; if it only partially matches or contains abnormal characters, the confidence score is lowered. Furthermore, the character recognition confidence score output by the OCR recognition model represents the matching probability between image pixels and recognized characters. If the OCR confidence score of a line of text is generally low, it suggests that the line may be blurry, occluded, or subject to noise interference, requiring extra caution in subsequent processing.
[0048] When obtaining multiple confidence levels of a single document primitive through various methods in (1)-(4) above, the multiple confidence levels can be weighted and summed based on preset weights, and then the weighted sum can be converted to a value in [0,1] as the fusion confidence level of the document primitive.
[0049] like Figure 2 As shown, document region 201 includes multiple document primitives 202. The confidence scores of these multiple document primitives can be statistically aggregated to obtain region-level confidence information 204 representing the entire document region. The aggregation process can employ various mathematical statistical methods, commonly including calculating the average, variance, minimum, or maximum confidence scores of all document primitives within the region. Specifically, statistical aggregation can be performed on the fused confidence scores of each of the multiple document primitives, or statistical aggregation can be performed on various types of confidence scores (such as structural confidence, OCR recognition confidence, etc.) of each of the multiple document primitives separately.
[0050] For example, suppose a document area Include The document primitive, the first The confidence level of each document primitive is First, calculate the average confidence level for that region. The formula is as follows:
[0051] (1)
[0052] in, Representative area The arithmetic mean of the confidence levels of all document primitives within a region reflects the overall trustworthiness of that region. If... A value close to 1 indicates that the vast majority of content within the area is clearly identifiable and has a simple and regular structure; if... A lower confidence level suggests poor overall quality in the region. However, the average alone is often insufficient to reveal potential risks because it can mask extreme local anomalies. Therefore, it is necessary to further calculate the variance of the confidence level. To quantify the fluctuations in quality within the region:
[0053] (2)
[0054] in, This describes the degree to which the confidence scores of each document primitive deviate from the average. In practical engineering, it has been found that while some document regions may have a high overall average confidence score, they may contain a small number of "noisy" rows with extremely low confidence scores (such as table borders being misidentified as text, header and footer interference, etc.), which can lead to a significant increase in variance. High variance often indicates that the internal structure of the region is complex or uneven, with local difficulties. If a uniform processing strategy is applied to such regions, errors are very likely to propagate at the noisy points. Therefore, variance is an important indicator for identifying "pseudo-simple" regions.
[0055] The minimum confidence level, excluding the mean and variance. It is also one of the key statistical characteristics:
[0056] (3)
[0057] in, This directly exposes the reliability of the weakest link in the region. According to the barrel effect, the overall quality of document structure recovery is often limited by the weakest part. If a region contains document primitives with a confidence level below the safety threshold (e.g., 0.3), regardless of how clear the other parts are, that region should be considered a potentially difficult area, as low-confidence rows may lead to missed headers, paragraph truncation, or misaligned table rows and columns. Through comprehensive analysis... , and These three statistics can construct a comprehensive picture of the quality distribution within a document region. For example, a high, low and A high-quality, simple region can be identified; while a Medium but Extremely high or Areas with extremely low risk levels will be marked as complex areas with hidden risks.
[0058] This statistical aggregation mechanism, from micro-level primitives to macro-level regions, provides solid data support for subsequent difficulty level classification. It avoids the drawbacks of relying solely on a single indicator (such as total word count or average font size) for rough estimation, enabling difficulty assessment to keenly capture fine-grained differences within the document. In practical applications, more advanced statistical measures can be introduced according to specific needs, such as skewness to determine the distribution tendency of low-confidence data, or quantiles (such as the 5th percentile) to replace the minimum value and eliminate interference from extreme outliers. These statistical features, together with the aforementioned extracted typesetting features, markup language tags, and business fields, constitute a multi-dimensional feature vector, which is input into the difficulty assessment module.
[0059] It's worth noting that there's an inherent coupling between metadata features and confidence information. In some cases, metadata features themselves can serve as a confidence adjustment factor. For example, if a document primitive has a low OCR recognition confidence, but its layout features show large, bold font and its business fields match typical heading numbering patterns, a weighted fusion approach can be used to improve the overall confidence of that primitive, avoiding misjudging it as invalid content due to simple recognition noise. Conversely, if a document primitive has a high OCR confidence, but its layout features (such as indentation and font size) severely conflict with the context or are inconsistent with the expected business logic, the confidence weight of its structural determination can be appropriately reduced. This dynamic cross-validation mechanism further enhances the robustness of feature extraction, ensuring that the generated region-level confidence information accurately reflects the structural complexity and processing difficulty of the document region.
[0060] Metadata features of a document region can also be obtained based on the metadata features of each document primitive within the document region. For example, metadata features of document primitives can be used to obtain metadata features of a document region.
[0061]
[0062]
[0063]
[0064]
[0065]
[0066]
[0067]
[0068] Metadata features such as tags and tab alignment determine whether complex tables are included within a document area. Metadata features such as font and language of each document primitive determine whether multiple languages / texts are mixed within the document area. Metadata features of each document primitive determine whether the document area includes paragraphs spanning multiple pages. Additionally, the metadata features and confidence levels of each document primitive within the document area can determine whether abnormal features are present. These abnormal features include, for example, at least one of the following: the proportion of lines with OCR confidence levels below a threshold is higher than the threshold; the proportion of lines containing abnormal characters is higher than the threshold; significant differences in font size within the document area; inconsistent indentation patterns; and severe loss of layout information. After obtaining the above metadata features and confidence level information, the process proceeds to step S130: based on the metadata features and confidence level information corresponding to each document area, the difficulty level of each document area is determined. In one implementation, the difficulty level can be divided into three levels: easy, normal, and difficult, each corresponding to different processing strategies. Easy areas typically have highly regular layout, high and stable confidence levels, and clear business logic; these areas can achieve satisfactory structure restoration results using low-cost processing strategies. In a specific example, a document region meeting the following criteria can be identified as a simple region: high average structure confidence and high minimum structure confidence; no complex tables, cross-page clauses, or multilingual text within the region; high OCR confidence with no obvious garbled characters; and stable layout features (font size, indentation). Difficult regions are characterized by complex layouts (such as nested tables or cross-page paragraphs), drastic fluctuations in confidence, significant OCR noise, or multilingual text. These regions require high-cost computational resources and the powerful inference capabilities of large models to ensure accurate structure parsing. In a specific example, a document region meeting the following criteria can be identified as a difficult region: low minimum structure confidence or drastic fluctuations in confidence; complex tables, deeply nested clauses, or multilingual text within the same document region; low OCR confidence and chaotic layout; and marked as "important text" (such as key contract clauses). Ordinary regions fall between these two categories, and processing strategies can be flexibly selected based on remaining resources. In a specific example, a document region meeting the following criteria can be identified as a normal region: moderate structural confidence with occasional local low-confidence headings / sides; moderate complexity of metadata features, etc. The difficulty level can be determined using preset scoring rules or a trained classification model. In the rule-based implementation, corresponding weights and thresholds can be assigned to each feature. For example, if a region contains complex table layout markers, the difficulty score is directly increased by a certain value; if the minimum confidence value is lower than a preset threshold (e.g., 0.5), the difficulty score is increased again; if the confidence variance exceeds a set range, it indicates uneven quality within the region, and the difficulty score continues to increase. The final comprehensive score determines the corresponding difficulty level based on which interval it falls into.This rule-driven approach offers good interpretability, allowing technicians to adjust threshold parameters based on actual business feedback. In the classification model-based implementation, metadata feature vectors and confidence statistics are concatenated and input into a binary or multi-class neural network, where the model automatically learns the non-linear relationship between features and difficulty levels. This approach performs better in scenarios with complex feature interactions, but requires a certain amount of labeled data for training. Regardless of the method used, the core objective is to accurately identify difficult regions, ensuring they receive sufficient attention in subsequent resource allocation. In one implementation, the metadata complexity feature detection logic is first executed, followed by pattern matching for several typical difficult scenarios. The first typical scenario is the detection of complex table layouts. Tables, especially nested or frameless tables, are often challenging for structure recovery. This can be addressed by scanning for markup language tags (such as those in HTML) within the area. 、 、 The presence of tables is identified by nesting levels or typographical features (such as dense vertical lines, regular indentation jumps, and multi-column alignment patterns). If the nesting depth of a table exceeds a preset threshold (e.g., more than 3 levels), or if a cell contains mixed-type child elements (e.g., images embedded in text, lists), the area is considered to have high complexity. Furthermore, for tables without frame boundaries, the coordinate distribution of document primitives can be analyzed. If multiple columns of text are found to have strict vertical alignment and the column spacing is significantly smaller than the row spacing, an implicit table structure is inferred. These areas involve logical reasoning about row and column relationships, making it easy to make mistakes using only lightweight rules; therefore, they tend to be marked as difficult areas.
[0069] The second typical scenario is the identification of cross-page content truncation. In long documents, a complete semantic unit (such as a long paragraph, a large table, or a list) is often cut off by physical page breaks, spreading across two or more adjacent pages. If regions are divided only by page without considering cross-page continuity, it will lead to a break in structural information. Such cases can be detected by examining document primitive features at region boundaries. For example, if the last line of text in a region ends with a non-ending punctuation mark (such as a comma or semicolon), and the first line of the next region begins with a lowercase letter or a non-heading style, or if a region ends with an unclosed table label, and the next region begins immediately with a table row label, then a cross-page truncation feature is identified. This feature suggests a strong dependency between regions, and processing the region alone may not provide a complete global view, thus increasing the processing difficulty.
[0070] The third typical scenario is the detection of multilingual mixed text and OCR recognition noise. In multilingual documents, the character sets, writing directions, and typesetting habits of different languages vary greatly, and a single model often struggles to maintain accuracy for all languages simultaneously. Language entropy values can be calculated by statistically analyzing the Unicode encoding distribution of characters within a region. If two or more major languages (such as Chinese and Arabic, or Chinese and Latin) are detected alternating frequently, this is marked as a multilingual mixed text feature. Simultaneously, for OCR recognition noise, the proportion of low-confidence document primitives within the region and the frequency of abnormal characters (such as garbled symbols, consecutive question marks, and special control characters) are statistically analyzed. If the noise ratio exceeds a set threshold, it indicates poor image quality or obscure fonts in that region, resulting in low reliability of the recognition results, requiring a more powerful model for contextual error correction and restoration.
[0071] After completing the Boolean or count type detection of the above metadata complexity features, such as Figure 3 As shown, a comprehensive difficulty score can be calculated by combining confidence statistical features and using preset scoring rules. In a specific embodiment, the difficulty score... The calculation formula can be designed as a linear weighted form:
[0072] (4)
[0073] in, These are the weighting coefficients for the mean, variance, and minimum, respectively, used to adjust the contribution of different statistics to the difficulty level. and The confidence level is converted into a risk value; the lower the confidence level, the higher the risk. For the first Penalty weights for metadata complexity features; As an indicator function, when the first... The value is 1 for complex features (such as complex tables, page breaks, etc.) and 0 otherwise. This formula clearly expresses the logic of difficulty assessment: areas with low overall confidence, large internal fluctuations, weak links, and complex layout features will receive higher difficulty scores.
[0074] Based on calculations This is compared with a preset threshold range to determine the difficulty level. and For two graded thresholds ( ).like If so, the document area is divided into simple regions. If so, the area is classified as a normal area. If so, the area is identified as a difficult area.
[0075] Threshold settings are not static but can be dynamically optimized based on actual business scenarios and historical data. In the initial deployment phase, a more conservative threshold setting can be adopted, classifying more areas into the difficult or normal categories to ensure overall accuracy. As operational data accumulates, by analyzing the actual processing effects of areas with different difficulty levels (such as manual sampling pass rates and downstream task feedback), the threshold parameters can be gradually optimized to make the difficulty classification more accurate. For example, if it is found that a large number of areas classified as "difficult" can actually be handled perfectly with a lightweight strategy, the threshold can be appropriately increased. A higher threshold can expand the coverage of simpler areas, thereby further reducing costs. Conversely, if structural errors frequently occur in certain "normal" areas, the threshold should be lowered. The threshold is used to include it in a higher priority protection scope.
[0076] In the implementation method of using a machine learning classification model to determine the difficulty level, the confidence statistical feature vector ( The input feature vector is formed by concatenating the metadata complexity feature vector (table depth, page cross marker, language entropy, etc.) with the metadata complexity feature vector. Pre-trained multi-class neural networks (such as multilayer perceptrons (MLPs) or gradient boosting trees (GBDTs) receive... As input, the output directly shows the probability distribution of belonging to the three categories: easy, normal, and hard. The final difficulty level is determined by the category with the highest probability. Compared to rule-based scoring, machine learning models can automatically learn complex non-linear interactions between features. For example, a model might learn that "difficulty increases exponentially when variance is large and cross-page features are present," a latent pattern that requires careful manual tuning to capture in rule-based systems. However, model-based methods have relatively weak interpretability and rely on high-quality labeled training data. In practical engineering, the two can be combined: using rule-based scoring as a foundation, the model output can be used to perform secondary calibration on cases with ambiguous boundaries, thus balancing interpretability and accuracy.
[0077] After determining the difficulty level, proceed to step S140: obtain the global inference budget, and assign a corresponding level of large language model processing strategy to each document region based on the global inference budget and the difficulty level of each document region.
[0078] The global inference budget is a constraint on the maximum amount of resources allowed to be consumed in the entire document processing task, typically expressed as the number of tokens, the number of large model calls, time limits, or monetary costs. Given limited resources, how to accurately allocate valuable computing power to where it is most needed is one of the core technical problems this solution addresses. Large language model processing strategies typically include at least two different tiers: a first processing strategy (high cost, high accuracy) and a second processing strategy (low cost, low accuracy). The first processing strategy may involve calling large models with a huge number of parameters, performing multiple sampling votes, or executing complex graph optimization algorithms, aiming to achieve the highest possible parsing accuracy; the second processing strategy may employ lightweight models, rule engines, or single-run fast inference, aiming to complete the basic structure extraction at minimal cost.
[0079] The allocation process is essentially a constrained combinatorial optimization problem. First, the expected resource consumption of each document region under different processing strategies can be estimated. This estimation can be based on the number of document primitives contained in the region, the length of the metadata string, and the average token consumption coefficient per primitive obtained from historical statistics. Then, a processing queue is constructed, prioritizing document regions according to their difficulty level, from high to low difficulty. When traversing this queue, if the current document region is a difficult or normal region, it is checked whether the remaining global inference budget is sufficient to support the use of the first processing strategy. If the budget is sufficient, the first processing strategy is prioritized for the difficult region to ensure that key difficulties are overcome; if the budget is insufficient, it is forced to be downgraded to the second processing strategy. If the current document region is a simple region, the second processing strategy is automatically assigned by default, unless in extreme cases where the budget is extremely abundant, in which case upgrading the strategy to further improve quality is considered.
[0080] Specifically, the budget scheduling module acts as the "command center" of the entire process, receiving classification results (easy, normal, hard) from the difficulty assessment module and combining them with a pre-set global reasoning budget. Output a list of strategy allocations for each document region. Global inference budget. This is a hard constraint, which can manifest as an upper limit on the number of tokens, the maximum allowed inference time (in seconds), or a preset limit on currency costs. In actual deployments, this budget is usually determined by the service level agreement (SLA) of the business scenario or the physical limits of hardware resources. For example, on edge computing devices, the budget may be limited by memory capacity and battery power; in cloud SaaS services, the budget directly corresponds to the user's payment amount or the system's concurrent processing capacity.
[0081] To make reasonable resource allocation decisions, the system first needs to quantify the resource requirements of each document region under different processing strategies, that is, estimate the expected resource consumption of each document region under the first and second processing strategies. The estimation of expected resource consumption is modeled based on the physical attributes and historical statistical data of the document regions. Let a certain document region... Include Each document primitive has a metadata string with a total length of . (Number of characters). The system pre-sets the average token consumption coefficient per primitive for different processing strategies. For the first processing strategy (high cost and high accuracy), due to the complex engineering of prompt words, multiple sampling, or multiple rounds of interaction, its consumption coefficient is high. Typically, the cost coefficient is relatively large; for the second processing strategy (low cost and low accuracy), due to the use of lightweight models or fast single-pass inference, its cost coefficient is relatively large. Relatively small and Expected resource consumption The following linear model can be used for estimation:
[0082] (5)
[0083] in, This is a correction factor for metadata length, used to compensate for the context window inflation effect caused by long text. This represents fixed overhead, including model loading, network transmission, and the token consumption of the Prompt template itself. This formula provides a fast and sufficiently accurate estimation method, allowing the system to pre-calculate the theoretical total resources required to process all regions before actually calling the large model. If the sum of the estimates for all regions using the first processing strategy exceeds... This indicates that a strategy downgrade is necessary, and high-precision mode cannot be used for all regions.
[0084] Based on the estimation results, the system initiates a greedy allocation algorithm. First, it prioritizes document regions according to their difficulty level, constructing a processing queue from highest to lowest difficulty. In this queue, all regions marked "Difficult" are at the front, followed by "Normal" regions, and finally "Easy" regions. Regions within the same difficulty level can be further sorted by expected resource consumption from lowest to highest, or by minimum confidence level from lowest to highest, to ensure that the most challenging or cost-effective regions are processed first. The processing queue is then traversed. The system maintains a dynamic variable. Represents the remaining global inference budget, initially. .
[0085] For the current document region in the queue The system executes the following judgment logic: First, check... Is it greater than or equal to the expected resource consumption of the region under the first processing strategy? If the condition is met ( If the budget is sufficient, the system assigns the first processing strategy to that region. The first processing strategy is typically configured to call a large language model with a huge number of parameters and extremely strong reasoning capabilities, supplemented by advanced operations such as multiple independent sampling, self-consistency voting, and graph structure optimization. Although this strategy is costly, it effectively handles challenging tasks such as complex table parsing, fuzzy title recognition, and cross-page logical reasoning, ensuring that the accuracy of structure restoration in key regions is close to human-level performance. After allocation, the system updates the remaining budget: .
[0086] If the conditions are not met ( This means the remaining budget is insufficient to support the use of a high-cost strategy in the current region. In this case, the system immediately downgrades the processing strategy for that region to a secondary processing strategy. The secondary processing strategy is configured to perform inference using a classification model (such as a lightweight BERT) or a rule engine. In an optimized embodiment, the secondary processing strategy is not simply a "lower-spec version," but includes a cascading fallback mechanism: first, the rule engine or lightweight model performs rapid inference; if its output confidence level is higher than a preset threshold, the result is directly adopted; only when the lightweight model's inference result indicates a confidence level lower than the threshold (i.e., the model also feels "uncertain") is a single inference attempt by the large language model attempted as a supplement. This design allows the secondary processing strategy to maintain a certain level of error correction capability while ensuring low cost. Regardless of the situation, once the decision is made to use the secondary processing strategy, the system deducts the corresponding lower cost. (Or mark it as allocated directly, to be deducted during actual runtime), and continue processing the next region in the queue.
[0087] In addition, the estimated values during the offline planning phase There is often a discrepancy between the actual resource consumption and the actual runtime consumption. The output length of a large language model is random, and the actual token consumption in some areas may far exceed expectations, leading to premature budget exhaustion. To address this uncertainty, this solution also introduces a runtime dynamic degradation mechanism. During the execution of structured processing, the system monitors the amount of resources consumed in real time. And dynamically update the remaining global inference budget. Whenever I'm ready to process a new document area At that time, the system not only refers to the pre-allocated _strategy_, but also performs an on-the-spot budget check.
[0088] If the current document region is detected The first processing strategy (high cost, high precision) has been assigned, but the current... If the resource consumption in a region falls below the minimum resource threshold (or the estimated actual consumption) required to execute the first processing strategy, the system immediately triggers a degradation action, dynamically switching the processing strategy for that region to the second processing strategy (low cost, low precision). This runtime circuit breaker mechanism prevents the situation where abnormal consumption in a single region causes all subsequent regions to become completely unprocessable, ensuring the continuity of the processing flow and the robustness of the system. For example, suppose a difficult region contains a large number of obscure characters or complex formulas, causing the large model to output an extremely long Chain of Thought, instantly consuming all remaining budget. Without dynamic degradation, subsequent regions would be forced to skip or report errors; with this mechanism, the system can automatically switch the current and subsequent regions to lightweight mode the moment it detects insufficient budget. Although the processing precision of subsequent regions will decrease, at least the output of complete structured results is guaranteed, avoiding task interruption.
[0089] The accuracy of the estimated resource consumption directly affects the scheduling effect. To improve estimation accuracy, the system can introduce an adaptive learning mechanism. After each processing step, the system records the actual consumption of each region. Compared with the estimated quantity deviation Using this historical deviation data, the system can periodically update the coefficients in formula (5). and Alternatively, a more accurate regression model can be trained to predict consumption. For example, if regions containing numerous mathematical formulas are found to be generally underestimated, the system can automatically increase the correction coefficient for such regions. This closed-loop feedback mechanism allows the budget scheduling algorithm to continuously evolve over time, gradually adapting to the document feature distribution under specific business scenarios.
[0090] In addition, global inference budget It can also be dynamically adjusted. In certain emergency scenarios, if the user is willing to pay additional costs or the system detects idle computing resources, Temporary expansion is possible, allowing more areas to be upgraded to the first-line processing strategy. Conversely, during periods of high system load, It can automatically scale back and force more regions to degrade to ensure the stability of core services. This flexible budget management mechanism further enhances the solution's adaptability to different application scenarios.
[0091] Through the aforementioned budget awareness and dynamic scheduling mechanism, the system successfully achieved optimal strategy allocation under limited resource constraints. Instead of treating all document regions equally, it performs differentiated resource allocation, fundamentally resolving the inherent conflict between cost and quality in existing technologies. This makes it possible to achieve high-precision structural recovery at a controllable cost in large-scale document processing scenarios.
[0092] Finally, in process execution step S150: according to the large language model processing strategy allocated to each document region, perform structured processing on each document region based on the semantics of each document region.
[0093] In this step, for regions assigned to the first processing strategy, a high-performance large model is invoked, possibly supplemented by multiple inferences and self-consistency checks, to deeply mine the internal heading hierarchy, paragraph boundaries, and table logic relationships, generating high-precision local structure results. For regions assigned to the second processing strategy, a lightweight process is employed, primarily based on preset rules and classifiers for structure judgment. In areas with local uncertainty, a large model is used for structure judgment, thereby quickly completing basic structure extraction. After all regions have been processed, subsequent merging and global optimization operations are performed to integrate the scattered local results into a consistent global hierarchical document structure and resolve hierarchical conflicts at cross-region boundaries. At this point, the entire document structuring processing workflow is complete, outputting structured data with both high accuracy and low cost.
[0094] Specifically, for difficult regions assigned the first processing strategy (high cost and high precision), multiple slightly different prompts are constructed based on the contextual content of the same document region, or processing is performed under a higher temperature parameter setting. Sub-inference sampling occurs at each stage. In each inference, the large model outputs a prediction of the heading level, paragraph boundaries, and table relationships within that region. For example, regarding whether a line of text is a third-level heading, the first sample might determine "yes," the second "no," and the third "yes." The system collects these predictions. The results of this inference are used to construct a result distribution matrix. Then, a self-consistent voting algorithm is executed to count the frequency of each structural judgment. If the frequency of a certain judgment (e.g., "is a third-level heading") exceeds a preset threshold (e.g., ...), a result distribution matrix is constructed. or If the result is not found in the large model, it is adopted as the final inference result. This mechanism utilizes the probabilistic characteristics of the large model and eliminates the randomness and illusion of single inference through ensemble learning, significantly improving the accuracy of judgment in complex scenarios. In addition, the first processing strategy may also include a graph structure optimization step, which transforms the output of the large model into graph nodes and uses graph algorithms to detect and repair local hierarchical conflicts (such as child nodes being higher than parent nodes), ensuring that the generated local structure is logically self-consistent.
[0095] Under the first processing strategy, the large model can be input with multi-line text, metadata features, and confidence information of the difficult region. Additionally, the large model can be input with the preliminary content hierarchy obtained during the confidence determination process.
[0096] For example, prompts for large models could be as follows:
[0097] You are a document structure recovery expert.
[0098] You are given a continuous multi-line text, each line containing content, formatting features, an initial title score from upstream sources, and a preliminary hierarchical pattern obtained from the previous structural analysis. Please, assuming you understand the overall semantics and official document writing conventions, describe:
[0099] 1. Determine if each line is a heading;
[0100] 2. If it is a title, provide a reasonable title hierarchy (1 / 2 / 3, etc.);
[0101] 3. For the header row, provide its suggested parent header line_id (if the parent header is outside the current window, you can fill in the line_id of the nearest level header in current_parent_path or mark it as "OUT_OF_WINDOW");
[0102] 4. If a line is not a heading but should be merged with the previous line into the same body text, please indicate this.
[0103] The large model outputs a judgment on the structure of each row in the difficult region. For example, it outputs the following for one row:
[0104] { "line_id": "L0048", "is_header": false, "header_level": null, "normalized_title": null, "parent_suggestion": "L0043", "merge_to_prev":false, "confidence": 0.74}
[0105] In contrast, for simple or ordinary regions assigned the second processing strategy (low cost, low precision), the rule engine can first directly output structural labels based on predefined layout templates (e.g., "font size greater than 14pt and bold indicates a title"). The lightweight classification model is then input with the feature vector corresponding to the simple region, outputting the category probability. This feature vector can be obtained based on the metadata features and confidence information of each document primitive included in the simple region. In an optimized embodiment, the second processing strategy introduces a confidence gating mechanism: if the confidence score of the rule engine or lightweight model's output is higher than a preset threshold (e.g., 0.85), the system directly adopts the result without calling the large model, thus greatly saving resources. If the inference result of the lightweight model indicates a confidence score lower than the threshold (indicating that the model is "uncertain" about the sample or is at the decision boundary), the system triggers a fallback mechanism, calling the large language model for a single inference. This single inference does not use multiple samplings and is only used as a supplementary correction for complex issues. This cascaded design enables the second processing strategy to maintain extremely low average cost while still being able to handle local anomalies, avoiding the vulnerability of pure rule-based solutions when faced with non-standard typesetting.
[0106] Specifically, under the second processing strategy, the text, metadata features, and confidence information of each row of the simple region can be input into the large model.
[0107] For example, prompts for large models could be as follows:
[0108] You are a document structure analysis assistant, responsible for determining whether a line of text is a heading.
[0109] Based solely on the given line text, its metadata features, and confidence information, determine whether the line is a header and its possible header level.
[0110] For example, a large model might make a judgment based on the output of each row. The output content for one row would be as follows:
[0111] { "is_header": true, "header_level": 2, "need_merge_to_prev": false, "confidence": 0.82}
[0112] Using the above method, the title lines of the document area are first determined. For non-title lines, continuous body text lines are determined based on indentation marks, line spacing, or semantic coherence. These continuous body text lines are then aggregated into paragraph blocks, and table-type lines are aggregated into table blocks, etc., ultimately resulting in the local skeleton tree of the document area.
[0113] like Figure 4 As shown, the local skeleton tree is a tree-like data structure where the root node represents the region itself, and child nodes represent the identified semantic units such as headings, paragraph blocks, and table blocks at various levels. Each node is accompanied by rich metadata, such as heading level (Level1, Level2...), starting line number, ending line number, and confidence score. Based on the generated local skeleton tree, the system further performs text segmentation, cutting the original text stream within the region into multiple semantically complete text chunks. The segmentation logic strictly follows the boundaries of the skeleton tree: it is usually segmented at leaf nodes (such as the smallest level headings or independent paragraphs), or, depending on the needs of downstream tasks, several consecutive low-level nodes are merged into a larger text chunk. Each text chunk not only contains plain text content but also inherits its path information in the skeleton tree (such as "Chapter 1 > Section 1 > Paragraph 1"). This path information is embedded in the text chunk as metadata, greatly enhancing the interpretability and accuracy of subsequent retrieval tasks.
[0114] After all document regions have undergone local processing, the scattered local skeleton trees need to be integrated into a globally consistent overall structure. Because the region divisions are manually truncated, hierarchical breaks or logical conflicts are highly likely to occur at the boundaries of adjacent regions. For example, the end of region A might be a second-level heading, while the beginning of region B might be misinterpreted as a first-level heading, causing a hierarchical jump; or a table spanning multiple pages might start in region A and end in region B, which, without processing, would be recognized as two independent tables. Therefore, the system performs global consistency checks and corrections, such as... Figure 5 As shown.
[0115] First, the local skeleton trees generated from all document regions are merged sequentially to construct the initial global skeleton tree. At this point, the initial global skeleton tree may have discontinuous "breaks" at region connections. The system scans and verifies these boundaries based on global hierarchical constraints. Global hierarchical constraints include: heading levels must monotonically decrease or remain at the same level before increasing (there cannot be a jump from Level 2 directly to Level 4 without Level 3), tables must have a beginning and an end, and list items must belong to the same parent node, among other logical rules. The system focuses on checking node pairs at the boundaries of adjacent regions (i.e., the last node of the previous region and the first node of the next region). If an abnormal hierarchical affiliation is found (e.g., the end of the first region is body text, but the beginning of the second region is a Level 1 heading, even though the semantics clearly indicate a subordinate relationship), the system initiates a correction algorithm.
[0116] The correction algorithm utilizes contextual semantics and the limited reasoning capabilities of the large model for boundary fusion. The system extracts several document primitives near the boundary and constructs a dedicated "boundary verification prompt" to query the large model whether there is an implicit parent-child or parallel relationship between these two nodes. If the large model confirms the existence of a relationship, the system adjusts the node attributes, such as downgrading the level of the heading at the beginning of the latter area, delaying the end marker of the former area to the latter area, or even merging two separate table nodes into a single complete table node spanning the entire area. Through this fine-grained verification and correction, the initial global skeleton tree is transformed into the corrected target hierarchical document structure. This structure maintains logical rigor and hierarchical continuity throughout the entire document, completely eliminating the fragmentation caused by chunked processing.
[0117] The final output hierarchical document structure and corresponding block results not only contain accurate text content but also retain complete logical topological relationships. This result can directly serve downstream knowledge base construction, question-answering systems, or data analysis tasks. Compared to existing technologies, this embodiment achieves maximum quality while controlling costs through the execution of differentiated strategies and global optimization. High-precision processing of difficult regions ensures the correct parsing of complex structures, low-cost processing of simple regions avoids resource waste, and global consistency correction ensures the integrity of the overall structure. This "divide and conquer" and then "unite" processing paradigm effectively solves the efficiency and quality contradiction in large-scale document structuring.
[0118] The embodiment consisting of steps S110 to S150 and their refinement processes can achieve the following technical effects: by introducing difficulty-aware dynamic resource scheduling, the system can significantly improve the accuracy of structural recovery of complex documents under the same budget, or significantly reduce the computational cost under the same accuracy requirements; through self-consistent voting and cascading fallback mechanisms, the robustness in high-difficulty and low-difficulty scenarios is enhanced respectively; through global boundary correction, the logical breaks caused by block processing are eliminated, and high-quality global structured data is output.
[0119] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program a digital system themselves to "integrate" it onto a PLD, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used when writing program development code. The original code before compilation must also be written in a specific programming language, which is called a Hardware Description Language (HDL). There is not just one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using the aforementioned hardware description languages and programming it into an integrated circuit, the hardware circuit that implements the logic method flow can be easily obtained.
[0120] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, ASICs, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0121] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not exclude the possibility that, with the future development of computer technology, the computer implementing the functions of the above embodiments can be, for example, a personal computer, a laptop computer, an in-vehicle human-machine interaction device, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0122] While one or more embodiments of this specification provide the operational steps of the methods described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive means. The order of steps listed in the embodiments is merely one possible order of execution among many steps and does not represent the only possible order. In actual device or end product execution, the methods shown in the embodiments or drawings may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even a distributed data processing environment). The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitations, the presence of other identical or equivalent elements in the process, method, product, or apparatus that includes said elements is not excluded. For example, the use of terms such as "first," "second," etc., is to denote names and does not indicate any particular order.
[0123] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, when implementing one or more of these specifications, the functions of each module can be implemented in one or more software and / or hardware components, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between devices or units, and may be electrical, mechanical, or other forms.
[0124] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0125] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0126] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0127] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0128] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0129] Computer-readable media include both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0130] Those skilled in the art will understand that one or more embodiments of this specification can be provided as a method, system, or computer program product. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0131] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0132] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, system embodiments are basically similar to method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. In the description of this specification, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this specification. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0133] The above description is merely an embodiment of one or more embodiments of this specification and is not intended to limit the scope of these embodiments. Various modifications and variations can be made to these embodiments by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims. < / h6>
Claims
1. A method for structuring documents, comprising: Divide the document to be processed into multiple document regions; Obtain metadata features and confidence information corresponding to each document region; Based on the metadata features and confidence information corresponding to each document region, the difficulty level of each document region is determined. Based on the global inference budget and the difficulty level of each document region, a corresponding level of large language model processing strategy is assigned to each document region. According to the large language model processing strategy for all document regions, each document region is processed in a structured manner.
2. The method for structuring documents as described in claim 1, wherein obtaining the metadata features and confidence information corresponding to each document region includes: Extract text from the document, the text comprising multiple document primitives; Obtain the layout features, markup language tags, or business fields corresponding to each document primitive as metadata features; Obtain the confidence level of each document primitive; The confidence scores of multiple document primitives belonging to the same document region are statistically aggregated to generate the confidence score information for that document region.
3. The method for structurally processing a document of claim 2, wherein, The determination of the difficulty level of each document region based on its corresponding metadata features and confidence information includes: Calculate the average, variance, or minimum confidence score of document primitives within each document region to obtain the statistical characteristics of the confidence score; Detect the presence of complex table layouts, page-crossing content truncation, multilingual text mixing, or OCR recognition noise in each document area to obtain metadata complexity features; Based on the confidence statistical features and the metadata complexity features, each document region is divided into simple regions, ordinary regions, or difficult regions using preset scoring rules.
4. The method for structurally processing a document of claim 1, wherein, The large language model processing strategy includes a first processing strategy and a second processing strategy. The first processing strategy has a higher large model inference cost than the second processing strategy. The large language model processing strategy that assigns corresponding levels to each document region includes: Estimate the expected resource consumption of each document region under the first processing strategy; The processing queue is constructed from high difficulty to low difficulty based on the difficulty level of the document area. The processing queue is traversed. When the current document region is a difficult region, if the remaining global inference budget is greater than or equal to the expected resource consumption of the current document region, the first processing strategy is used to process the current document region; if the remaining global inference budget is less than the expected resource consumption of the current document region, the second processing strategy is used to process the current document region.
5. The method for structurally processing a document of claim 4, wherein, The first processing strategy includes: performing multiple inferences through several large language models, and determining the final inference result based on the results of the multiple inferences; The second processing strategy includes: performing inference through a classification model or rule engine, and performing a single inference through a large model when the confidence level indicated by the inference result of the classification model or rule engine is lower than a preset threshold.
6. The method for structurally processing a document of claim 2, wherein, The structural processing of each document region includes: By utilizing the assigned large language model processing strategy, the heading levels, paragraph boundaries, and table logical relationships within each document region are identified, and a local skeleton tree is generated. Based on the local skeleton tree and the semantics of each document region, the text corresponding to each document region is segmented into multiple text blocks.
7. The method for structuring documents as described in claim 6, wherein, The method further includes: Merge the local skeleton trees generated from all document regions to construct the initial global skeleton tree; Based on global hierarchical constraints, consistency verification and correction are performed on the title hierarchy and parent-child connection relationship at the boundaries of adjacent document regions in the initial global skeleton tree. Output the corrected target hierarchical document structure and the corresponding block results.
8. The method for structuring documents as described in claim 2, wherein, The typesetting features include at least one of the following: font size, bolding state, indentation distance, alignment method, or line spacing; The markup language tags include HTML tag types, DOM tree node paths, or XML tag attributes; The business fields include the clause number, account type, fee type, or currency.
9. The method for structuring documents as described in claim 4, wherein, The expected resource consumption is estimated based on the number of document primitives contained in each document region, the length of the metadata string, and the resource consumption corresponding to a single document primitive.
10. A computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-9.