Large model-based document title hierarchy restoration method and device and computer equipment
Patent Information
- Application Number
- CN202611518034.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-29
- Publication Date
- 2026-10-30
AI Technical Summary
规则识别依赖编号样式、字体大小、加粗样式或缩进等显式特征;版面特征识别更多用于 PDF 等固定版式文件;机器学习分类方法可学习段落特征但容易在编号断裂、目录混入、列表项与标题混杂等场景下出现局部错误;大语言模型直接处理全文虽然具有较强语义理解能力,但在长文档场景中存在上下文长度受限、调用成本高、输出不可控、结构一致性难以保证等问题
[0038]上述基于大模型的文档标题层级还原方法、装置、计算机设备、计算机可读存储介质和计算机程序产品,通过序列标注模型对结构事件序列进行全局顺序建模,获得事件级的初始标签和初始标题层级,再通过异常检测识别可能存在标题角色或标题层级错误的局部异常候选片段,并仅对局部异常候选片段及其上下文调用辅助判定模型进行复核,最后根据辅助判定结果生成待处理文档中各段落的标题角色和标题层级,避免了将整篇文档直接输入大语言模型,减少了大语言模型的输入长度、调用次数和处理时间,适用于长文档的批量处理场景;通过局部异常检测,能够集中处理容易出错的局部区域,提高了标题角色和标题层级识别的准确性;通过将序列标注模型的全局顺序建模能力与辅助判定模型的局部语义判断能力相结合,既保持了全局结构的稳定性,又能够处理局部复杂语义,提高了长文档标题层级还原的准确性、稳定性和可解释性。
Smart Images

Figure CN123013849A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of document data processing technology, and in particular to a method, apparatus, computer device, computer-readable storage medium, and computer program product for restoring document title hierarchy based on a large model. Background Technology
[0002] In applications such as electronic document parsing, knowledge base construction, retrieval-augmented generation (RAG), contract review, policy document management, and intelligent office document formatting, it is often necessary to accurately restore the title roles and heading levels from long documents. The heading level not only affects the table of contents structure, document navigation, and structured display, but also further affects subsequent text segmentation, knowledge indexing, question and answer location, and structured export results.
[0003] Traditional techniques for document heading hierarchy recognition typically employ rule-based recognition, layout feature recognition, machine learning classification, or large language models directly generating a structure tree. Rule-based recognition relies on explicit features such as numbering style, font size, bolding style, or indentation; layout feature recognition is more suitable for fixed-format documents like PDFs; machine learning classification methods can learn paragraph features but are prone to local errors in scenarios with broken numbering, table of contents inclusion, or mixed list items and headings; while large language models directly processing the entire text have strong semantic understanding capabilities, they suffer from limitations in context length, high calling costs, uncontrollable output, and difficulty in ensuring structural consistency in long document scenarios. All these current methods suffer from low accuracy in reconstructing heading hierarchies in long documents. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for restoring document title levels based on a large model, which can improve the accuracy of restoring the title level of long documents, in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a method for restoring document title hierarchy based on a large model, including:
[0006] Obtain the paragraph sequence of the document to be processed. For paragraphs in the paragraph sequence that meet the preset structural tendency conditions, construct structural events in paragraph order to obtain a structural event sequence. The structural event is an event that represents the structural tendency of the corresponding paragraph in the document structure. The structural event corresponds to a numbered skeleton. The numbered skeleton is a normalized numbering structure abstracted from the paragraph number prefix of the corresponding paragraph.
[0007] The event features of each of the structural events are input into the sequence labeling model to obtain the initial label of each structural event and the confidence level corresponding to the initial label; the initial label includes title candidate label, list candidate label and unstructured noise label;
[0008] Based on the initial tags and the number skeleton of each structural event, the structural events marked with the title candidate tags are decoded at the title level to obtain the initial title level of the structural events marked with the title candidate tags;
[0009] Based on the initial label and the initial title level, anomaly detection is performed on the structured event sequence to determine abnormal candidate segments; the abnormal candidate segments include a set of structured events in the structured event sequence that may have title role and / or title level errors;
[0010] The abnormal candidate fragment and its context, the initial label and initial title level corresponding to each structural event in the abnormal candidate fragment are input into the auxiliary judgment model to obtain the title role and title level output by the auxiliary judgment model, and the title role and title level of each paragraph in the document to be processed are generated according to the title role and title level output by the auxiliary judgment model; the auxiliary judgment model includes a large language model.
[0011] In one embodiment, generating the title role and title level of each paragraph in the document to be processed based on the title role and title level output by the auxiliary determination model includes:
[0012] The output of the auxiliary decision-making model is verified according to the preset constraint verification rules;
[0013] The outputs that pass the verification are written back to the structured event sequence, and the initial labels and initial title levels of the corresponding structured events are updated; for the outputs that fail the verification, the initial labels and initial title levels of the corresponding structured events remain unchanged.
[0014] Based on the updated initial labels and the updated initial title levels, abnormal candidate segments are re-determined, and the process returns to the step of inputting the abnormal candidate segments and their contexts, the initial labels and initial title levels corresponding to each structural event in the abnormal candidate segments into the auxiliary decision model, until there are no abnormal candidate segments in the structural event sequence.
[0015] Based on the updated initial tags and the updated initial heading levels, generate the heading roles and heading levels for each paragraph in the document to be processed.
[0016] In one embodiment, the step of verifying the output of the auxiliary decision model according to preset constraint verification rules includes:
[0017] The output of the auxiliary judgment model shall be subjected to at least one of the following checks: format verification, role validity verification, hierarchy validity verification, number continuity verification, parent-child relationship verification, and local consistency verification.
[0018] The format verification verifies that the output of the auxiliary judgment model meets a parsable structured format; the role validity verification verifies that the title role output by the auxiliary judgment model belongs to a preset role set; the hierarchy validity verification verifies that the title hierarchy output by the auxiliary judgment model is within a preset hierarchy range; the number continuity verification verifies that the number skeleton corresponding to the structured event judged as a title satisfies the same level, parent-child, or preset jump relationship as the number skeleton of the context structured event; the parent-child relationship verification verifies that lower-level title structured events do not appear in isolation; and the local consistency verification verifies that the title role and title hierarchy of structured events with the same or similar number skeletons within the same abnormal candidate segment are consistent.
[0019] In one embodiment, the step of performing anomaly detection on the structural event sequence based on the initial label and the initial title level to determine anomaly candidate segments includes:
[0020] When a structural event in the structural event sequence is determined to meet the abnormal triggering condition based on the initial label and the initial title level, the corresponding structural event is identified as the target event, and the target event and its adjacent structural events are merged into the abnormal candidate fragment.
[0021] The abnormal triggering conditions include at least one of the following conditions: the structural event labeled as the title candidate tag cannot form a valid sibling or parent-child progressive relationship with adjacent structural events according to its numbered skeleton and initial title level; among multiple adjacent structural events with the same or similar numbered skeletons, the initial tag includes at least two of the following: title candidate tag, list candidate tag, and non-structural noise tag; the initial title level of the structural event exceeds a preset maximum level, or a level jump occurs relative to adjacent structural events that cannot be explained by the numbered skeleton; the confidence level of the structural event is lower than a preset threshold.
[0022] In one embodiment, the auxiliary judgment model includes a large language model; the step of inputting the abnormal candidate fragment and its context, the initial label and initial title level corresponding to each structural event in the abnormal candidate fragment into the auxiliary judgment model, and obtaining the title role and title level output by the auxiliary judgment model includes:
[0023] Based on the paragraph information, initial label, initial title level and number skeleton corresponding to each structural event in the abnormal candidate segment, as well as the preset number of context paragraphs before and after the abnormal candidate segment, and the sample events that match the number skeleton of each structural event in the abnormal candidate segment, auxiliary judgment input data is constructed.
[0024] The auxiliary judgment input data is input into the large language model to obtain the title role and title level of each structural event in the abnormal candidate fragment output by the large language model.
[0025] In one embodiment, the step of decoding the structure events labeled with the title candidate tags based on the initial tags and the number skeletons of each structure event to obtain the initial title level of the structure events labeled with the title candidate tags includes:
[0026] If the number skeleton of the structural event and the number skeleton at the top of the stack of the hierarchical state stack corresponding to the document to be processed satisfy the same hierarchical continuity relationship, then the initial title level of the structural event is determined to be the same as the title level at the top of the stack; the hierarchical state stack is used to record the number skeleton and title level of the structural events in the document to be processed that have been identified as titles.
[0027] If the number skeleton of the structured event is a direct child of the number skeleton at the top of the stack, then the initial title level of the structured event is determined to be one level deeper than the title level at the top of the stack.
[0028] If the number skeleton of the structured event satisfies the same or child relationship as the structured event at a higher title level, then the title level is determined after the title state stack is rolled back to the higher title level.
[0029] Secondly, this application also provides a document title hierarchy restoration device based on a large model, comprising:
[0030] The acquisition module is used to acquire the paragraph sequence of the document to be processed. For the paragraphs in the paragraph sequence that meet the preset structural tendency conditions, structural events are constructed in the order of the paragraphs to obtain a structural event sequence. The structural event is an event that represents the structural tendency of the corresponding paragraph in the document structure. The structural event corresponds to a number skeleton. The number skeleton is a normalized numbering structure abstracted from the paragraph number prefix of the corresponding paragraph.
[0031] The annotation module is used to input the event features of each of the structural events into the sequence labeling model to obtain the initial label of each structural event and the confidence level corresponding to the initial label; the initial label includes title candidate label, list candidate label and non-structural noise label;
[0032] The decoding module is used to perform title-level decoding on the structural events marked with the title candidate tags based on the initial tags and the number skeleton of each structural event, so as to obtain the initial title level of the structural events marked with the title candidate tags;
[0033] The detection module is used to perform anomaly detection on the structured event sequence based on the initial tag and the initial title level, and determine the abnormal candidate segments; the abnormal candidate segments include a set of structured events in the structured event sequence that may have title role and / or title level errors;
[0034] The generation module is used to input the abnormal candidate fragment and its context, the initial label and initial title level corresponding to each structural event in the abnormal candidate fragment into the auxiliary judgment model to obtain the title role and title level output by the auxiliary judgment model, and to generate the title role and title level of each paragraph in the document to be processed based on the title role and title level output by the auxiliary judgment model; the auxiliary judgment model includes a large language model.
[0035] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.
[0036] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0037] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described method.
[0038] The aforementioned document title hierarchy restoration method, apparatus, computer device, computer-readable storage medium, and computer program product based on a large model utilizes a sequence labeling model to perform global sequential modeling of structural event sequences, obtaining initial event-level labels and initial title levels. Then, anomaly detection identifies potential local anomaly candidate segments with errors in title roles or title levels. Only these local anomaly candidate segments and their contexts are reviewed using an auxiliary judgment model. Finally, based on the auxiliary judgment results, the title roles and title levels of each paragraph in the document to be processed are generated. This avoids directly inputting the entire document into a large language model, reducing the input length, number of calls, and processing time of the large language model, making it suitable for batch processing of long documents. Local anomaly detection allows for focused processing of error-prone local areas, improving the accuracy of title role and title level identification. By combining the global sequential modeling capability of the sequence labeling model with the local semantic judgment capability of the auxiliary judgment model, the stability of the global structure is maintained while handling complex local semantics, improving the accuracy, stability, and interpretability of long document title hierarchy restoration. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is an application environment diagram of a document title hierarchy restoration method based on a large model in one embodiment;
[0041] Figure 2 This is a flowchart illustrating a document title hierarchy restoration method based on a large model in one embodiment;
[0042] Figure 3 This is a schematic diagram of the architecture of a document title hierarchy restoration system based on a large model in one embodiment;
[0043] Figure 4 This is a flowchart of a document title hierarchy restoration method based on a large model in one embodiment;
[0044] Figure 5 This is a structural block diagram of a document title hierarchy restoration device based on a large model in one embodiment;
[0045] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0047] The document title hierarchy restoration method based on a large model provided in this application can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104, or it can be located in the cloud or on another network server.
[0048] Terminal 102 acquires the paragraph sequence of the document to be processed. For paragraphs in the paragraph sequence that meet the preset structural tendency conditions, structural events are constructed in paragraph order to obtain a structural event sequence. A structural event is an event that represents the structural tendency of the corresponding paragraph in the document structure. Each structural event has a corresponding number skeleton, which is a normalized numbering structure abstracted from the paragraph's initial number prefix. Terminal 102 inputs the event features of each structural event into the sequence labeling model to obtain the initial label of each structural event and the confidence level corresponding to the initial label. The initial labels include title candidate labels, list candidate labels, and non-structural noise labels. Based on the initial labels and the number skeleton of each structural event, terminal 102 labels the structural events that are marked as title candidate labels. The terminal 102 performs title level decoding to obtain the initial title level of the structural events labeled as title candidate tags; based on the initial tags and initial title levels, the terminal 102 performs anomaly detection on the structural event sequence to determine anomaly candidate segments; the anomaly candidate segments include a set of structural events in the structural event sequence that may have title role and / or title level errors; the terminal 102 inputs the anomaly candidate segments and their context, the initial tags and initial title levels corresponding to each structural event in the anomaly candidate segments into the auxiliary judgment model to obtain the title role and title level output by the auxiliary judgment model, and generates the title role and title level of each paragraph in the document to be processed based on the title role and title level output by the auxiliary judgment model; the auxiliary judgment model includes a large language model.
[0049] The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. The server 104 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server providing cloud computing services.
[0050] In one exemplary embodiment, such as Figure 2As shown, a document title hierarchy restoration method based on a large model is provided, and the method is applied to Figure 1 the terminal 102 in the following as an example for description, the method includes:
[0051] Step S202: Obtain the paragraph sequence of the to-be-processed document, and construct structural events for the paragraphs in the paragraph sequence that meet the preset structural tendency condition in the order of the paragraphs, so as to obtain a structural event sequence.
[0052] Herein, the paragraph sequence may be a set of paragraphs arranged in the order of document paragraphs, and each paragraph in the paragraph sequence corresponds to a respective paragraph number, which is used to identify the position of the paragraph in the linear text. The to-be-processed document may be a document in DOCX format, a document in PDF format, a web page document, a plain text document, or the like; for a document in an image format such as a scanned copy, the document may be converted into text through Optical Character Recognition (OCR) technology in advance, then the text is extracted according to a paragraph or line sequence, and basic standardization processing is performed, for example, removing invisible characters, unifying the representation of line breaks and blanks, etc. The paragraph sequence is used to provide processing objects for subsequent structural event construction.
[0053] Herein, the preset structural tendency condition may refer to a condition for judging whether a paragraph has a tendency to become a component of the document structure. For example, the preset structural tendency condition may include: there is a number prefix at the start of the paragraph; the paragraph has preset format features, such as bolding, font size change, indentation, etc.; the paragraph is located near a chapter boundary, etc. The number prefix may refer to a number text located at the start of the paragraph, which is composed of numbers, Chinese serial numbers, brackets, dots, enumeration commas, chapter prompt words, etc., for example, "一、", "(一)", "1.", "1.1", "Chapter 1", etc. When a paragraph meets the preset structural tendency condition, it may be considered that the paragraph has a structural tendency, and then the paragraph is constructed as a structural event; when a paragraph does not meet the preset structural tendency condition, no structural event may be constructed, or the paragraph may be constructed as an event of other types, which is not limited in this embodiment.
[0054] Herein, the structural event is an event that characterizes the structural tendency of the corresponding paragraph in the document structure. In other words, the structural event is used to characterize the structural tendency of the paragraph in the restoration of heading hierarchies, and is not equivalent to the final heading hierarchy result. A paragraph may form a structural event when a preset structure trigger condition is satisfied, or may not trigger a structural event, so the number of structural events may be different from the number of paragraphs. Exemplarily, the structural event may be triggered by a numbering prefix at the beginning of a paragraph or other structural prefixes, and the event information corresponding to the structural event may include the paragraph line number, paragraph text, numbering prefix, numbering skeleton, numbering value sequence, numbering depth, and the body interval from the previous structural event, etc. The numbering value sequence may refer to a sequence composed of the numbering values of all levels in the numbering prefix, for example, the numbering value sequence corresponding to the numbering prefix "1.2.3" is [1,2,3]; the numbering depth may refer to the number of levels contained in the numbering prefix, for example, the numbering depth of the numbering prefix "1.2.3" is 3; the body interval may refer to the number or distance of body paragraphs between adjacent structural events.
[0055] Herein, the structural event corresponds to a numbering skeleton, which is a normalized numbering structure abstracted from the numbering prefix at the beginning of the corresponding paragraph. In other words, the numbering skeleton may refer to a normalized numbering structure abstracted from the numbering prefix at the beginning of the paragraph. The normalized numbering structure may refer to a numbering structure obtained by unifying numbers that have different writing forms but the same structural meaning into the same representation form. For example, numbers such as "一、", "(一)", "1.", "1.1", and "Chapter 1" can be parsed into numbering skeletons of different levels or different types. The numbering skeleton is used to determine whether adjacent paragraphs satisfy a same-level consecutive, parent-child progressive, or abnormal jump relationship. Optionally, a numbering skeleton function may be configured to extract the numbering structure from the paragraph text corresponding to the structural event, so as to convert the numbering prefix into a normalized numbering skeleton.
[0056] In a specific implementation, constructing structural events according to the paragraph order may be performing numbering prefix identification, numbering skeleton extraction, and context relationship analysis on paragraphs that satisfy the preset structural tendency condition in sequence according to the sequential order of the paragraphs in the paragraph sequence, and constructing the paragraphs that satisfy the condition into structural events in order, so as to obtain a structural event sequence.
[0057] For example, the process of generating structural events may include: normalizing the paragraph text; extracting a numbering prefix from the beginning of the paragraph, consisting of numbers, Chinese serial numbers, parentheses, punctuation marks, commas, chapter headings, etc.; determining whether the numbering prefix has a stable structural meaning; normalizing the valid numbers into a numbering skeleton and retaining the specific numbering value sequence; and calculating the text interval between adjacent structural events. For common noise such as citations, page numbers, figure captions, formula numbers, and hyperlinks, the likelihood of them being constructed as candidate title events can be reduced by combining their occurrence position, text form, and contextual continuity. For example, when a paragraph is a page number or citation text, the paragraph may not be constructed as a structural event, or it may be constructed as a structural event with low priority.
[0058] For ease of description, we can assume the document paragraph sequence is as follows: ,in Let n represent the i-th paragraph and n be the total number of paragraphs; construct a structural event sequence from the paragraph sequence P using preset structural rules or feature extraction logic. ,in Let represent the j-th structural event, and m be the number of structural events, where m and n can be different. We can define the numbering skeleton function as follows: Used from structured events Extract the numbered structure from the corresponding paragraph text to obtain the structure event. The numbered skeleton.
[0059] For example, when a paragraph begins with "1.2", it can form a multi-level Arabic numeral structured event; when a paragraph's numbering skeleton is continuous with the preceding and following paragraphs, the continuity relationship with the skeleton can be reflected in the contextual features of the structured event. The structured events in the sequence are arranged according to the order of their corresponding paragraphs, and the structured event sequence is used as input for subsequent sequence labeling models.
[0060] Step S204: Input the event features of each structural event into the sequence labeling model to obtain the initial label of each structural event and the confidence level corresponding to the initial label.
[0061] Event features can refer to features used to describe the attributes of a structural event itself and its contextual relationships. For example, event features may include at least one of the following: numbering features, numbering skeleton features, text morphology features, contextual relationship features, formatting style features, document location features, and model confidence correlation features.
[0062] The numbering feature describes whether a number is present at the beginning of a paragraph and the specific form of the number. It can include whether there is a paragraph header number, the number type, the number value sequence, the number depth, the number separator, whether the number is located at the beginning of a paragraph, and whether the number is followed by a space or punctuation mark. The number type can include Chinese numerals, Arabic numerals, bracket numbers, chapter numbers, multi-level numbers, clause numbers, etc.
[0063] Among them, the number skeleton feature is used to describe the normalized structure of the number skeleton. It can include the current paragraph number skeleton, whether the current number is at the same level as the previous number, whether the current number is a direct child of the previous title number, whether the current number has the same skeleton relationship with the historical title, whether the current number jumps or breaks, and whether the current number is a single large number. Through this type of feature, the probability of page numbers, years, amounts and other numbers being misidentified as title numbers can be reduced.
[0064] Among them, text morphological features are used to describe the morphology of paragraph text, which may include paragraph length, length of the main text after numbering, number of non-whitespace characters, whether it is short text, whether it is close to a complete sentence, whether it ends with punctuation such as period, semicolon, colon or comma, and whether it contains structural prompt words such as "chapter", "section", "article", "clause", "appendix", "table" and "figure". As an optional extension, it is also possible to add table of contents prompts, explanatory text prompts, abnormal blank prompts, and common noise prompts such as citations, page numbers, chart descriptions, formula numbers, and hyperlinks, depending on the document type.
[0065] Among them, the context relationship feature is used to describe the structural relationship between the current paragraph and the paragraphs before and after it. It can include the numbering type of the paragraphs before and after it, the length of the paragraphs before and after it, whether the paragraphs before and after it are title candidates, the numbering density within the local window, the proportion of short paragraphs within the local window, whether adjacent numbers are consecutive, whether adjacent numbers span levels, and whether the current paragraph is located in a title-dense area.
[0066] Among them, format style features are used to describe the format information of paragraphs, which may include font size, whether it is bold, whether it is centered, indentation, line spacing, style name, whether it has a heading style, etc. For PDF or OCR scenarios, format style features may also include the bounding box of characters or text blocks, font size, page position, line height and layout area information.
[0067] Among them, document location features are used to describe the relative position of the current paragraph in the entire document, which may include paragraph number, relative paragraph position, whether it is at the beginning of the document, whether it is near the table of contents, whether it is at the beginning of a chapter, page number or position within a page, etc.
[0068] Among them, model confidence-related features may include label edge probabilities, label confidence, adjacent label transition scores, or low-confidence markers output by the sequence labeling model. These features can be used for subsequent anomaly candidate detection, or as reference information for manual review or to assist in model judgment.
[0069] It should be noted that not all of the above features must be used simultaneously. In specific implementation, some features can be selected and combined according to the document type. For example, numbering features, numbering skeleton features, text morphology features, and contextual relationship features are used to form basic event features; when format information can be obtained, format style features and document position features are further introduced to improve adaptability to complex document layouts.
[0070] The sequence labeling model refers to a model used to label sequences of structured events. Optionally, the sequence labeling model can be a Conditional Random Field (CRF) model, or a BiLSTM-CRF model, Transformer-CRF model, or other models capable of modeling the dependencies between adjacent labels. Based on the structured events and their contextual relationships, the sequence labeling model outputs an initial label and marginal probabilities for each structured event. The marginal probability of the label can be the probability value predicted by the sequence labeling model for a structured event to be labeled with a corresponding label category; the marginal probability of the label can be used as the confidence level of the corresponding initial label.
[0071] For ease of description, we can assume that the sequence of feature vectors for each structural event in the structural event sequence is . ,in Let m be the feature vector of the j-th structural event, and m be the number of structural events; the sequence labeling model outputs the initial label sequence. ,in Let j be the initial label for the j-th structural event. Each initial label may have a confidence level. .
[0072] Initial labels can refer to the labels output by the sequence labeling model, used to characterize the initial coarse roles of structural events. Initial labels can include title candidate labels, list candidate labels, and unstructured noise labels.
[0073] The title candidate label is used to characterize the tendency of a structural event to become a title. It can include title start and title continuation. Title start is used to indicate the first structural event in a title-numbered running segment, and title continuation is used to indicate subsequent structural events in the same title running segment.
[0074] Among them, the list candidate label is used to characterize the tendency of a structural event to become a list item. It can include list start and list continuation. List start is used to indicate the first event in a numbered list or item list, and list continuation is used to indicate subsequent events in the list.
[0075] Among them, unstructured noise labels are used to characterize structural events that, although they have forms such as numbers, brackets, references, page numbers, and chart descriptions, are not adopted as titles or lists.
[0076] The above labels only describe the coarse roles of structural events and do not directly provide the title tree. The final title level is determined by subsequent numbered skeleton decoding and local auxiliary decoding.
[0077] Here, confidence level refers to the reliability of the initial label, used to characterize the credibility of a structural event being labeled with its corresponding initial label. Optionally, the confidence level can be represented by the marginal probability of the label output by the sequence labeling model. For common noise such as citations, page numbers, chart descriptions, formula numbers, and hyperlinks, the confidence level of their labeling as candidate title labels can be reduced by combining their occurrence position, text form, and contextual continuity.
[0078] In practical applications, the initial label sequence of each structural event can be used as input for subsequent header-level decoding and anomaly detection.
[0079] Step S206: Based on the initial labels and the number skeleton of each structural event, perform title level decoding on the structural events marked as title candidate labels to obtain the initial title level of the structural events marked as title candidate labels.
[0080] Heading level decoding refers to the process of determining the heading level for structural events labeled as heading candidates. Heading levels characterize the level of a heading within the document structure, such as level 1, level 2, etc. The initial heading level can be the intermediate result obtained from heading level decoding; this initial heading level can be corrected in subsequent processing.
[0081] For example, heading level decoding can be based on the structural relationships between numbered skeletons. These relationships can include sibling continuation, parent-child progression, etc. Sibling continuation refers to two numbered skeletons of the same type with consecutive number values, such as "1." and "2."; parent-child progression refers to a later numbered skeleton being a direct child of the earlier one, such as "1." and "1.1". During decoding, the initial heading level of the current structural event can be determined based on the structural relationship between the numbered skeleton of the current structural event and the numbered skeleton of the confirmed heading. For example, if the numbered skeleton of the current structural event and the numbered skeleton of the confirmed heading satisfy a sibling continuation relationship, the current structural event is in the same position as the confirmed heading in the document heading structure; if the numbered skeleton of the current structural event and the numbered skeleton of the confirmed heading form a parent-child progression relationship, the current structural event is located at the next level below the confirmed heading in the document heading structure; if the numbered skeleton of the current structural event and a higher-level confirmed heading satisfy a sibling or child relationship, the initial heading level of the current structural event can be determined based on that higher level. Optionally, the number skeleton and title level of the confirmed title can be recorded using hierarchical status information, and the hierarchical status information can be dynamically updated as the decoding process progresses. More implementation methods of hierarchical status information will be described in subsequent embodiments.
[0082] It should be noted that title-level decoding is only performed on structural events labeled as title candidate tags; structural events labeled as list candidate tags or non-structural noise tags are not included in title-level decoding. The result of title-level decoding is the initial title level, which is used as input for subsequent anomaly detection and auxiliary judgment.
[0083] Step S208: Based on the initial labels and initial title levels, perform anomaly detection on the structural event sequence to determine anomalous candidate segments.
[0084] Among them, the abnormal candidate fragments include a set of structural events in the structural event sequence that may contain title role and / or title level errors.
[0085] In practice, anomaly detection can refer to the process of identifying structural events in a sequence of structural events that may have incorrect heading roles and / or heading levels, based on initial labels and initial heading levels. Heading roles can be used to characterize the structural role of the paragraph corresponding to a structural event within the document, such as heading, list paragraph, or body text.
[0086] Among them, an abnormal candidate segment can refer to a small set of continuous or neighboring events that may have title role or title level errors, detected by preset rules or statistical conditions in the initial event prediction sequence.
[0087] In specific implementation, when a structural event in the structural event sequence is determined to meet the anomaly triggering conditions based on the initial label and initial title level, the corresponding structural event can be identified as the target event, and the target event and its adjacent structural events can be merged into anomaly candidate segments. The target event can refer to a structural event detected as potentially having title roles and / or title levels errors. Anomaly triggering conditions may include situations such as structural events failing to form a valid structural relationship, roles being mixed in running segments with the same number, an abnormal initial title level, and a confidence level lower than a preset threshold. Specific settings for anomaly triggering conditions will be explained in subsequent embodiments.
[0088] Optionally, the abnormal candidate fragments may include information such as the set of target events, the context before and after the target event, the candidate triggering reason, and the current prediction state. The candidate triggering reason explains the basis for identifying the fragment as an abnormal candidate fragment, facilitating subsequent manual review and model debugging. When merging abnormal candidate fragments, target events with the same or similar number skeletons and adjacent positions can be merged into one abnormal candidate fragment; if the number of events in the merged candidate fragment exceeds a preset threshold, it is split according to the event order to control the input length of the auxiliary judgment model. Each abnormal candidate fragment retains the triggering reason, context, auxiliary judgment result, and verification result, facilitating subsequent manual review, debugging, and model optimization.
[0089] For example, after identifying the target event, the boundaries of candidate anomaly segments can be determined according to a preset context window, adjacent skeleton events with the same number, the same consecutive numbered segments, or the same local hierarchical path. Candidate anomaly segments can be a set of consecutive events or a set of nearest neighbors consisting of the target event and its preceding and following contexts. These candidate anomaly segments serve as the input range for subsequent auxiliary decision-making models.
[0090] Step S210 involves inputting the candidate abnormal segment and its context, along with the initial labels and initial heading levels corresponding to each structural event within the candidate abnormal segment, into the auxiliary decision-making model. This yields the heading roles and heading levels output by the auxiliary decision-making model. Furthermore, based on the heading roles and heading levels output by the auxiliary decision-making model, the heading roles and heading levels for each paragraph in the document to be processed are generated. The auxiliary decision-making model can refer to a model used to assist in the decision-making of candidate abnormal segments. The auxiliary decision-making model includes large language models.
[0091] In specific implementation, the auxiliary judgment model can be a large language model (LLM), which has semantic understanding capabilities and can judge local anomalies in combination with context; or, the auxiliary judgment model can be a finely tuned small model, rule engine, or human-machine review interface, etc. This embodiment does not limit the specific type of auxiliary judgment model.
[0092] The context can refer to the content before and after the candidate segment of an anomaly. For example, the context may include a preset number of paragraphs before the candidate segment of anomaly and a preset number of paragraphs after the candidate segment of anomaly. By inputting the candidate segment of anomaly and its context, as well as the initial labels and initial title levels corresponding to each structural event, into the auxiliary judgment model, the auxiliary judgment model can review each structural event in the candidate segment of anomaly based on an understanding of the local structural background, and output the title role and title level of each structural event.
[0093] For example, the output of the auxiliary decision-making model may include information such as the title role, title level, whether it is adopted, and the reasons or confidence statements for each target event or target paragraph. The "whether it is adopted" indicates whether the output is recommended for adoption; the reasons or confidence statements indicate the basis or credibility of the output. The output of the auxiliary decision-making model is used as the basis for generating the title roles and title levels of each paragraph in the document to be processed. The candidate segment set can be set as follows: Each candidate fragment This includes the target event set, the preceding and following context, the candidate triggering reasons, and the current prediction state; for each candidate segment... Construct a local auxiliary decision input and submit it to the auxiliary decision model to obtain the title role and title level of each target event in the candidate segment.
[0094] In practical implementation, the title roles and titles output by the auxiliary judgment model can be used as the title roles and titles of the corresponding structural events in the anomaly candidate segments; for structural events outside the anomaly candidate segments, their initial labels and initial titles can be used as the corresponding title roles and titles. Based on this, and combining the correspondence between each structural event and paragraph, the title roles and titles of each paragraph in the document to be processed are generated, thus obtaining the title level mapping H for each paragraph. This indicates that the i-th paragraph is the k-th level heading. The heading level mapping is used to represent the correspondence between each paragraph and the heading role and heading level.
[0095] Optionally, at least one of the following processes can be performed based on the heading role and heading level of each paragraph: heading structure display, document table of contents generation, document segmentation, structured indexing, manual review, or document format rewriting. For example, a document table of contents can be generated based on the heading role and heading level of each paragraph; alternatively, the document can be segmented according to heading level, and the segmentation results can be used for knowledge base construction or retrieval enhancement generation.
[0096] The following explanation uses a long policy document as an example. This document contains several levels of headings, numbered lists, a table of contents, body text, and tables. The system extracts text in paragraph order, forming a paragraph sequence. Some paragraphs have numbers such as "I.", "(I)", "1.", and "1.1", and several short list items resemble headings. The system first identifies paragraphs with numbered prefixes or other structural tendencies, constructs structural events, and extracts event features such as numbering skeletons, text length, paragraph styles, and preceding / following numbering relationships. These features are then input into the sequence labeling model to obtain the initial label sequence. Some structural events, due to the similarity between list items and headings, may be labeled as candidate heading labels by the initial model; others may be labeled as candidate list labels or non-structural noise labels. For example, in the initial prediction, paragraph 42 could be marked as the beginning or continuation of a heading; after candidate detection and auxiliary judgment, if it is confirmed as a list of responsibilities, it can be rewritten as the beginning or continuation of a list, thus forming a closed loop between the initial labels, auxiliary judgment, and decision rewriting. The system detects the following abnormal candidate segments: a title candidate event cannot be placed into the current title state stack; title candidate tags, list candidate tags, or unstructured noise tags appear simultaneously in segments with the same number; the roles of segments with the same number that have text intervals are inconsistent; a title level undergoes a jump that cannot be explained by the parent-child relationship of the numbering. The system inputs these candidate segments and their context into a large language model for auxiliary judgment, without submitting the full text. The large language model returns parsable, structured, local judgment results. The system checks whether each target line number belongs to a candidate segment, whether the role is valid, whether the title level is within the preset range, and whether the numbering relationship is consistent with the context. For decisions that pass the verification, the system writes back the event prediction sequence; for decisions that fail the verification, the system keeps the original prediction and records the reason. Finally, the system outputs the structural role, title level, judgment source, and confidence information for each paragraph.
[0097] The aforementioned method for restoring document title hierarchy based on a large model uses a sequence labeling model to perform global sequential modeling of the structural event sequence, obtaining initial event-level labels and initial title hierarchy. Then, anomaly detection identifies potential local anomaly candidate segments with errors in title roles or title hierarchy. Only these local anomaly candidate segments and their contexts are reviewed by an auxiliary judgment model. Finally, based on the auxiliary judgment results, the title roles and title hierarchy of each paragraph in the document to be processed are generated. This avoids directly inputting the entire document into a large language model, reducing the input length, number of calls, and processing time of the large language model, making it suitable for batch processing of long documents. Local anomaly detection allows for focused processing of error-prone local areas, improving the accuracy of title role and title hierarchy identification. By combining the global sequential modeling capability of the sequence labeling model with the local semantic judgment capability of the auxiliary judgment model, the stability of the global structure is maintained while handling complex local semantics, improving the accuracy, stability, and interpretability of long document title hierarchy restoration.
[0098] For the convenience of those skilled in the art, Figure 3 An exemplary schematic diagram of a document title hierarchy restoration system based on a large model is provided. The document title hierarchy restoration method based on the large model can be applied to the restoration system, which may include the following units.
[0099] The document paragraph sequence acquisition unit is used to receive the document to be processed, extract the text by paragraph or line sequence, and perform basic normalization processing.
[0100] The structural event feature extraction unit is used to construct structural events based on information such as paragraph number, number skeleton, text length, punctuation pattern, indentation, style, relationship between adjacent paragraphs, and context position, and to extract structural event features.
[0101] The sequence labeling prediction unit is used to output the initial coarse label and confidence level for each structured event based on a Conditional Random Field (CRF) or other sequence labeling models.
[0102] The local anomaly candidate detection unit is used to detect suspected erroneous segments on the initial event prediction sequence and form a set of candidate segments.
[0103] The local auxiliary decision unit of the large language model is used to construct local prompt words for candidate segments and call the large language model to output auxiliary decision results.
[0104] The constraint verification and decision write-back unit is used to verify the output of the large language model and write back the verification results to the event prediction sequence.
[0105] The hierarchical decoding generation unit is used to infer the title hierarchy based on the corrected event prediction sequence and output the title role, title level, confidence level, and correction source.
[0106] In another embodiment, generating the title roles and title levels of each paragraph in the document to be processed based on the title roles and title levels output by the auxiliary judgment model includes: validating the output of the auxiliary judgment model according to preset constraint verification rules; writing back the output that passes the verification to the structural event sequence and updating the initial labels and initial title levels of the corresponding structural events; keeping the initial labels and initial title levels of the corresponding structural events unchanged for the output that fails the verification; re-determining abnormal candidate segments based on the updated initial labels and updated initial title levels, and returning to the step of inputting the abnormal candidate segments and their context, the initial labels and initial title levels corresponding to each structural event in the abnormal candidate segments to the auxiliary judgment model, until there are no abnormal candidate segments in the structural event sequence; and generating the title roles and title levels of each paragraph in the document to be processed based on the updated initial labels and updated initial title levels.
[0107] Among them, the preset constraint verification rules can refer to the set of rules used to verify whether the output of the auxiliary judgment model meets the preset constraints. This is to ensure that the output of the auxiliary judgment model conforms to the basic rules of document structure and avoid output that does not conform to the preset format or structural constraints from destroying the global structure. The specific content of the preset constraint verification rules will be explained in subsequent embodiments.
[0108] Here, "write-back" refers to the process of writing the auxiliary judgment result that has passed the verification back to the structured event sequence. In specific implementation, for outputs that pass the verification, the title role and title level corresponding to the output are updated to the initial label and initial title level of the corresponding structured event; for outputs that fail the verification, the initial label and initial title level of the corresponding structured event are not updated, that is, the original prediction result is maintained, or the abnormal candidate segment is marked as awaiting manual review.
[0109] In practical applications, after an anomalous candidate fragment is written back, the initial label and initial title level of the corresponding structural event in the structural event sequence change, which may lead to changes in whether other structural events meet the anomalous triggering conditions. Therefore, anomalous candidate fragments can be re-determined based on the updated initial label and updated initial title level, and the process returns to the step of inputting the anomalous candidate fragments into the auxiliary decision model until no anomalous candidate fragments remain in the structural event sequence. During the iteration process, if an anomalous candidate fragment is no longer anomalous due to previous decisions, it is skipped; if it still meets the anomalous triggering conditions, the auxiliary decision input is reconstructed for auxiliary decision-making. This candidate refresh mechanism avoids early local corrections from erroneously affecting subsequent candidates.
[0110] In this embodiment, by constraining and verifying the output of the auxiliary judgment model, only the results that pass the verification are written back to the structural event sequence, thus avoiding global structural damage caused by outputs that do not conform to the preset format or structural constraints, format errors, or hierarchical jumps; by iterative processing until there are no abnormal candidate segments, it ensures that all potentially erroneous local areas are checked, improving the accuracy of title hierarchy restoration; and by the candidate refresh mechanism, it ensures that local corrections will not have an erroneous impact on subsequent processing, thus improving the stability of the processing results.
[0111] In another embodiment, the output of the auxiliary judgment model is verified according to preset constraint verification rules, including: performing at least one of the following verification methods on the output of the auxiliary judgment model: format verification, role validity verification, hierarchy validity verification, number continuity verification, parent-child relationship verification, and local consistency verification; wherein, format verification verifies that the output of the auxiliary judgment model meets a parsable structured format; role validity verification verifies that the title role output by the auxiliary judgment model belongs to a preset role set; hierarchy validity verification verifies that the title hierarchy output by the auxiliary judgment model is within a preset hierarchy range; number continuity verification verifies that the number skeleton corresponding to the structural event judged as a title satisfies the same level, parent-child, or preset jump relationship with the number skeleton of the context structural event; parent-child relationship verification verifies that the lower-level title structural event does not appear in isolation; and local consistency verification verifies that the title role and title hierarchy of structural events with the same or similar number skeletons within the same abnormal candidate segment are consistent.
[0112] In practice, the preset constraint verification rules can include verification rules such as format verification, role validity verification, hierarchy validity verification, number continuity verification, parent-child relationship verification, and local consistency verification.
[0113] Among them, format validation is used to verify that the output of the auxiliary judgment model meets the parsable structured format, and that the line number of the target paragraph involved in the output exists in the corresponding abnormal candidate segment. Format validation can avoid subsequent processing failures due to output format errors.
[0114] Among them, the role validity check is used to verify that the title role output by the auxiliary judgment model belongs to the preset role set. The preset role set can include roles such as title, list paragraph, and body text. By checking the role validity, the auxiliary judgment model can avoid outputting roles outside the preset role set.
[0115] The hierarchy validity check is used to verify that the title hierarchy output by the auxiliary judgment model is within the preset hierarchy range. The preset hierarchy range can be set according to the document type, for example, it can be from level one to level twelve. The hierarchy validity check can prevent the output of title hierarchy that exceeds the preset range.
[0116] Among them, the number continuity check is used to check whether the number skeleton corresponding to the structural event that is determined to be the title satisfies the same level, parent-child or preset jump relationship as the number skeleton of the context structural event. The number continuity check can avoid problems such as conflict between title role and number skeleton and hierarchical jump.
[0117] Among them, the parent-child relationship check is used to check that the lower-level heading structure events do not occur in isolation. That is, the lower-level heading structure events do not occur when there is no corresponding parent-level heading structure event. The parent-child relationship check can avoid the occurrence of isolated lower-level headings that lack parent headings.
[0118] Among them, the local consistency check is used to check that the title role and title level of structural events with the same or similar number skeletons within the same abnormal candidate segment are consistent. The local consistency check can avoid the problem of inconsistent roles within the same numbered running segment.
[0119] It should be noted that the above verification methods can be used individually or in combination. In specific implementation, some verification methods can be selected according to the document type and business requirements.
[0120] Optionally, the preset constraint validation rules can be fixed rules, configurable rules, or rules dynamically generated based on confirmed title paths. Fixed rules are suitable for documents with relatively stable structures; configurable rules allow for different validation parameters to be configured according to different document types; rules dynamically generated based on confirmed title paths can dynamically determine the allowed numbering relationships based on the current hierarchical status of confirmed titles, improving the adaptability of the validation.
[0121] In this embodiment, the output of the auxiliary judgment model is constrained and verified in multiple dimensions through various verification methods such as format, role, hierarchy, numbering continuity, parent-child relationship and local consistency. This avoids problems such as hierarchical jumps, invalid parent-child relationships, conflicts between title roles and numbering skeletons, and incorrect promotion of list items to titles. As a result, the results written back to the structural event sequence conform to the document structure rules, and the global consistency of the title hierarchy restoration results is improved.
[0122] In another embodiment, anomaly detection is performed on the structured event sequence based on the initial label and the initial title level to determine anomaly candidate segments, including: when a structured event in the structured event sequence is determined to meet the anomaly triggering condition based on the initial label and the initial title level, the corresponding structured event is determined as the target event, and the target event and its adjacent structured events are merged into anomaly candidate segments.
[0123] The abnormal triggering conditions include at least one of the following: A structural event labeled as a title candidate tag cannot form a valid sibling or parent-child progressive relationship with adjacent structural events based on its numbered skeleton and initial title level; among multiple adjacent structural events with the same or similar numbered skeletons, the initial tags include at least two of the following: title candidate tags, list candidate tags, and non-structural noise tags; the initial title level of a structural event exceeds a preset maximum level, or a level jump relative to adjacent structural events occurs that cannot be explained by the numbered skeleton; the confidence level of a structural event is lower than a preset threshold. These four abnormal triggering conditions are described below.
[0124] The first type of abnormal triggering condition mentioned above can also be called the title stack placement failure condition. When a structural event is determined to be a title candidate by the sequence labeling model, but a valid sibling or parent-child progressive relationship cannot be formed according to the number skeleton, number value sequence, and current title state stack, it indicates that the structural event may be misjudged as a title, or there are omissions in the structural events before and after it.
[0125] The second type of abnormal triggering condition mentioned above can also be called the role confusion condition for the same numbered running segment. When multiple adjacent or near-adjacent structural events have the same or similar numbered skeletons, and the numbering values change continuously, but title candidate labels, list candidate labels, or unstructured noise labels appear simultaneously in the initial labels, it indicates that there is role confusion within the same numbered running segment. Further, this condition can also include the case of title and list confusion, that is, title candidate labels and list candidate labels appear alternately in the same local window, and the text length, numbering skeleton, or subsequent text form are similar, indicating that list items may be misidentified as titles, or titles may be misidentified as lists; and the case of list and noise confusion, that is, list candidate labels and unstructured noise labels are mixed in the same numbered running segment, and the numbering values are continuous or the text form is consistent, indicating that some events may be missed or mislabeled.
[0126] The third type of abnormal triggering condition mentioned above can also be called a level too deep or a jump condition. The preset maximum level can be set according to the document type, for example, it can be set to twelve levels. A level jump can refer to a change in the current title level relative to the previous confirmed title that cannot be explained by the parent-child relationship of the numbering.
[0127] The fourth type of abnormal triggering condition mentioned above can also be called the low confidence condition. The preset threshold can be set according to the model performance and business requirements. In one possible implementation, when the confidence of a structural event is lower than the preset threshold, and the structural event is located in a dense numbering area, a dense title area, or other local areas where titles and lists are easily confused, the structural event is determined to meet the abnormal triggering condition.
[0128] As an optional extension, the anomaly triggering conditions may also include: several structural events with the same numbered skeleton are interspersed with text paragraphs, and the roles of the preceding and following structural events are inconsistent. This situation may correspond to a mixture of chapter titles, paragraph lists, or explanatory numbers, requiring further judgment. Optionally, the anomaly triggering conditions can also be extended according to the document type, such as adding rules for table of contents detection, table title detection, figure caption title detection, or legal clause number detection.
[0129] In practical applications, after identifying the target event, the target event and its adjacent structural events can be merged into anomaly candidate segments. Specifically, the boundaries of anomaly candidate segments can be determined according to a preset context window, adjacent skeleton events with the same number, the same consecutive numbered segments, or the same local hierarchical path. If multiple target events are close to each other, have the same numbered skeleton, or are in the same numbered running segment, these target events can be merged into one anomaly candidate segment; if the number of events in a candidate segment exceeds a preset threshold, it is split according to the event order to control the input length of the auxiliary judgment model.
[0130] In this embodiment, by setting multiple abnormal trigger conditions, structural events that may have title role or title level errors can be identified from different dimensions. This covers a variety of abnormal scenarios such as title stack placement failure, mixed roles of running segments with the same number, mixed titles and lists, mixed lists and noise, excessively deep or abrupt levels, and low confidence. This improves the coverage and accuracy of abnormal detection, allowing auxiliary judgment resources to be concentrated on local areas that truly need review, thus avoiding the waste of auxiliary judgment resources.
[0131] In another embodiment, the auxiliary judgment model includes a large language model; inputting the abnormal candidate segment and its context, the initial tags and initial title levels corresponding to each structural event in the abnormal candidate segment into the auxiliary judgment model to obtain the title roles and title levels output by the auxiliary judgment model includes: constructing auxiliary judgment input data based on the paragraph information, initial tags, initial title levels and number skeletons corresponding to each structural event in the abnormal candidate segment, a preset number of context paragraphs before and after the abnormal candidate segment, and sample events that match the number skeletons of each structural event in the abnormal candidate segment; inputting the auxiliary judgment input data into the large language model to obtain the title roles and title levels of each structural event in the abnormal candidate segment output by the large language model.
[0132] The paragraph information can include the line number and text of the paragraph corresponding to the structural event. The context paragraphs can refer to a preset number of paragraphs before and after the candidate anomaly segment. This preset number can be set according to the context length of the large language model and the document type; for example, it can be set to the five paragraphs before and after the candidate anomaly segment. Sample events can refer to sample events or sample paragraphs that have the same or similar numbered skeletons as the structural events in the candidate anomaly segment. For example, a structural event in the currently confirmed title path with the same numbered skeleton as the target event. Providing sample events can provide a reference for the large language model, helping it understand the common roles of structural events with the same numbered skeleton in the document.
[0133] Optionally, the auxiliary input data may also include the currently confirmed heading level status or local heading path, as well as constraints requiring the large language model to output a parsable, structured result. The currently confirmed heading level status or local heading path provides the large language model with the global state of the current document heading structure; the constraints guide the large language model to output the judgment result in a preset format, facilitating subsequent verification and processing.
[0134] For example, the output of a large language model may include information such as the structural role, heading level, adoption status, reasons, or confidence statements for each target event or target paragraph. The structural role may include headings, list paragraphs, body text, etc.; the adoption status indicates whether the output is recommended for adoption; and the reasons or confidence statements indicate the basis or credibility of the output. The large language model can output the above information in a parsable, structured format, such as a preset key-value pair format, for subsequent verification and write-back.
[0135] In this embodiment, by constructing auxiliary judgment input data that includes paragraph information, context paragraphs, sample events, and confirmed heading level status, the entire document is avoided from being submitted to the large language model, reducing the input length and allowing the large language model to focus on the local segments that need to be judged. By providing sample events with the same numbered skeleton and confirmed heading level status, sufficient judgment references are provided for the large language model, improving the accuracy and structural consistency of the auxiliary judgment results.
[0136] In another embodiment, based on the initial label and the number skeleton of each structural event, the structural events marked as title candidate labels are decoded at the title level to obtain the initial title level of the structural events marked as title candidate labels. This includes: if the number skeleton of the structural event and the number skeleton at the top of the stack of the hierarchical state stack corresponding to the document to be processed satisfy a sibling relationship, then the initial title level of the structural event is determined to be the same as the title level at the top of the stack; the hierarchical state stack is used to record the number skeleton and title level of the structural events in the document to be processed that have been confirmed as titles; if the number skeleton of the structural event is a direct child of the number skeleton at the top of the stack, then the initial title level of the structural event is determined to be one level deeper than the title level at the top of the stack; if the number skeleton of the structural event and the structural event at a higher title level satisfy a sibling or child relationship, then the hierarchical state stack is backed up to the higher title level before determining the initial title level.
[0137] Among them, the hierarchical state stack can refer to the stack structure used to record the numbered skeleton of structural events that have been identified as titles in the document to be processed, as well as the title level.
[0138] Among them, the stack top number skeleton can refer to the number skeleton recorded by the top element of the stack in the hierarchical state stack, and the stack top title level can refer to the title level recorded by the top element of the stack in the hierarchical state stack.
[0139] Among them, the same level of continuity can refer to two number skeletons having the same type and consecutive number values. For example, the number skeletons "1." and "2." satisfy the same level of continuity. The direct child can refer to the next number skeleton being the next level of the previous number skeleton. For example, the direct child of the number skeleton "1." is "1.1".
[0140] For example, suppose the document to be processed contains structured events with the following skeletons: "1.", "1.1", "1.1.1", "1.2", and "2.", and all of these structured events are labeled as candidate title tags. Initially, the hierarchical state stack is empty. For the structured event with the skeleton "1.", since the hierarchical state stack is empty, it can be determined that the initial title level of this structured event is level one. The skeleton and title level of this structured event are then pushed onto the hierarchical state stack, at which point the top skeleton is "1." and the top title level is level one. For the structured event with the skeleton "1.1", since its skeleton is a direct child of the top skeleton "1.", it can be determined that the initial title level of this structured event is one level deeper than the top title level, i.e., level two. The skeleton and title level of this structured event are then pushed onto the hierarchical state stack. For the structured event with the skeleton "1.1.1", since its skeleton is a direct child of the top skeleton "1.1", it can be determined that the initial title level of this structured event is level three. For a structure event with the skeleton number "1.2", its skeleton number does not satisfy the same level of continuity as the top-of-stack skeleton number "1.1.1", nor is it a direct child of the top-of-stack skeleton number. However, its skeleton number "1.2" satisfies the same level of continuity as the structure event with the skeleton number "1.1" in a higher-level title hierarchy. Therefore, the title hierarchy stack can be backtracked to the title hierarchy corresponding to the skeleton number "1.1", and the initial title hierarchy of this structure event can be determined as level two. Similarly, for a structure event with the skeleton number "2.", its skeleton number does not satisfy the same level of continuity as the top-of-stack skeleton number "1.2", nor is it a direct child of the top-of-stack skeleton number. However, its skeleton number "2." satisfies the same level of continuity as the structure event with the skeleton number "1." in a higher-level title hierarchy. Therefore, the title hierarchy stack can be backtracked to the title hierarchy corresponding to the skeleton number "1.", and the initial title hierarchy of this structure event can be determined as level one.
[0141] In this embodiment, the number skeleton and title level of the confirmed title are recorded through a hierarchical state stack. The title level is decoded based on the rules of continuous siblings, direct children, and backtracking. The hierarchical relationship implied by the number skeleton can be used to determine the title level. The decoding process does not rely on an auxiliary judgment model, resulting in low computational cost. At the same time, the maintenance method of the hierarchical state stack is simple and can adapt to complex scenarios such as broken numbers and hierarchical jumps, thereby improving the accuracy and stability of the initial title level decoding.
[0142] For the convenience of those skilled in the art, Figure 4An exemplary flowchart of a document title hierarchy restoration method based on a large model is provided, including the following steps: initializing a document paragraph sequence and assigning a sequence number to each paragraph; constructing a structured event sequence and extracting event-level features; outputting initial coarse labels and confidence scores through a sequence labeling model; performing initial hierarchy decoding based on the initial coarse labels and numbered skeletons; detecting local abnormal candidate segments; constructing local auxiliary decision inputs for the large language model for the candidate segments; obtaining the output of the large language model and performing constraint verification; writing back the verified local decisions to the global event prediction sequence; refreshing the candidate context and continuing to process subsequent candidates until there are no more candidates to be processed; generating the title hierarchy result based on the final event prediction sequence.
[0143] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0144] Based on the same inventive concept, this application also provides a large-model-based document title hierarchy restoration apparatus for implementing the large-model-based document title hierarchy restoration method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method. Therefore, the specific limitations of one or more large-model-based document title hierarchy restoration apparatus embodiments provided below can be found in the limitations of the large-model-based document title hierarchy restoration method described above, and will not be repeated here.
[0145] In one exemplary embodiment, such as Figure 5 As shown, a document title hierarchy restoration device based on a large model is provided, including:
[0146] The acquisition module 510 is used to acquire the paragraph sequence of the document to be processed. For the paragraphs in the paragraph sequence that meet the preset structural tendency conditions, structural events are constructed in the order of the paragraphs to obtain a structural event sequence. The structural event is an event that represents the structural tendency of the corresponding paragraph in the document structure. The structural event corresponds to a number skeleton. The number skeleton is a normalized numbering structure abstracted from the paragraph number prefix of the corresponding paragraph.
[0147] The annotation module 520 is used to input the event features of each of the structural events into the sequence labeling model to obtain the initial label of each of the structural events and the confidence level corresponding to the initial label; the initial label includes title candidate label, list candidate label and non-structural noise label.
[0148] The decoding module 530 is used to perform title level decoding on the structural events marked with the title candidate tags in the structural events according to the initial tags and the number skeleton of each structural event, so as to obtain the initial title level of the structural events marked with the title candidate tags.
[0149] The detection module 540 is used to perform anomaly detection on the structured event sequence based on the initial label and the initial title level, and determine the abnormal candidate segments; the abnormal candidate segments include a set of structured events in the structured event sequence that may have title role and / or title level errors.
[0150] The generation module 550 is used to input the abnormal candidate fragment and its context, the initial label and initial title level corresponding to each structural event in the abnormal candidate fragment into the auxiliary judgment model to obtain the title role and title level output by the auxiliary judgment model, and to generate the title role and title level of each paragraph in the document to be processed based on the title role and title level output by the auxiliary judgment model; the auxiliary judgment model includes a large language model.
[0151] In one embodiment, the generation module 550 is specifically used to verify the output of the auxiliary judgment model according to preset constraint verification rules; write back the output that passes the verification to the structural event sequence, and update the initial label and initial title level of the corresponding structural event; for the output that fails the verification, keep the initial label and initial title level of the corresponding structural event unchanged; redetermine the abnormal candidate segment based on the updated initial label and updated initial title level, and return to the step of inputting the abnormal candidate segment and its context, the initial label and initial title level corresponding to each structural event in the abnormal candidate segment to the auxiliary judgment model, until there is no abnormal candidate segment in the structural event sequence; generate the title role and title level of each paragraph in the document to be processed according to the updated initial label and updated initial title level.
[0152] In one embodiment, the generation module 550 is specifically used to perform at least one of the following checks on the output of the auxiliary judgment model: format verification, role validity verification, hierarchy validity verification, number continuity verification, parent-child relationship verification, and local consistency verification. Specifically, the format verification checks that the output of the auxiliary judgment model meets a parsable structured format; the role validity verification checks that the title role output by the auxiliary judgment model belongs to a preset role set; the hierarchy validity verification checks that the title hierarchy output by the auxiliary judgment model is within a preset hierarchy range; the number continuity verification checks that the number skeleton corresponding to the structural event judged as a title satisfies a sibling, parent-child, or preset jump relationship with the number skeleton of the context structural event; the parent-child relationship verification checks that lower-level title structural events do not appear in isolation; and the local consistency verification checks that the title role and title hierarchy of structural events with the same or similar number skeletons within the same abnormal candidate segment are consistent.
[0153] In one embodiment, the detection module 540 is specifically configured to, when determining that a structural event in the structural event sequence satisfies an anomaly triggering condition based on the initial label and the initial title level, identify the corresponding structural event as a target event and merge the target event and its adjacent structural events into the anomaly candidate fragment; wherein, the anomaly triggering condition includes at least one of the following conditions: the structural event labeled as the title candidate tag cannot form a valid sibling or parent-child progressive relationship with adjacent structural events according to its number skeleton and initial title level; among multiple adjacent structural events with the same or similar number skeletons, the initial label includes at least two of the following: title candidate tag, list candidate tag, and non-structural noise tag; the initial title level of the structural event exceeds a preset maximum level, or a level jump relative to adjacent structural events occurs that cannot be explained by the number skeleton; the confidence level of the structural event is lower than a preset threshold.
[0154] In one embodiment, the auxiliary judgment model includes a large language model; the generation module 550 is specifically used to construct auxiliary judgment input data based on the paragraph information, initial tags, initial title levels and number skeletons corresponding to each structural event in the abnormal candidate segment, a preset number of context paragraphs before and after the abnormal candidate segment, and sample events that match the number skeletons of each structural event in the abnormal candidate segment; and input the auxiliary judgment input data into the large language model to obtain the title role and title level of each structural event in the abnormal candidate segment output by the large language model.
[0155] In one embodiment, the decoding module 530 is specifically configured to determine that the initial title level of the structural event is the same as the top title level of the stack if the number skeleton of the structural event and the number skeleton of the top of the stack of the hierarchical state stack corresponding to the document to be processed satisfy a sibling relationship; the hierarchical state stack is used to record the number skeleton and title level of the structural events that have been identified as titles in the document to be processed; if the number skeleton of the structural event is a direct child of the number skeleton of the top of the stack, the initial title level of the structural event is determined to be one level deeper than the top title level; if the number skeleton of the structural event satisfies a sibling or child relationship with a structural event of a higher title level, the hierarchical state stack is backed to the higher title level before determining the initial title level.
[0156] Each module in the aforementioned document title hierarchy restoration device based on a large model can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0157] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a method for restoring document title hierarchy based on a large model.
[0158] Those skilled in the art will understand that Figure 6The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0159] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0160] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0161] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0162] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0163] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0164] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0165] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for restoring document title hierarchy based on a large model, characterized in that, The method includes: Obtain the paragraph sequence of the document to be processed. For paragraphs in the paragraph sequence that meet the preset structural tendency conditions, construct structural events in paragraph order to obtain a structural event sequence. The structural event is an event that represents the structural tendency of the corresponding paragraph in the document structure. The structural event corresponds to a numbered skeleton. The numbered skeleton is a normalized numbering structure abstracted from the paragraph number prefix of the corresponding paragraph. The event features of each of the structural events are input into the sequence labeling model to obtain the initial label of each structural event and the confidence level corresponding to the initial label; the initial label includes title candidate label, list candidate label and unstructured noise label; Based on the initial tags and the number skeleton of each structural event, the structural events marked with the title candidate tags are decoded at the title level to obtain the initial title level of the structural events marked with the title candidate tags; Based on the initial label and the initial title level, anomaly detection is performed on the structured event sequence to determine abnormal candidate segments; the abnormal candidate segments include a set of structured events in the structured event sequence that may have title role and / or title level errors; The abnormal candidate fragment and its context, the initial label and initial title level corresponding to each structural event in the abnormal candidate fragment are input into the auxiliary judgment model to obtain the title role and title level output by the auxiliary judgment model, and the title role and title level of each paragraph in the document to be processed are generated according to the title role and title level output by the auxiliary judgment model; the auxiliary judgment model includes a large language model.
2. The method according to claim 1, characterized in that, The step of generating the title roles and title levels of each paragraph in the document to be processed based on the title roles and title levels output by the auxiliary determination model includes: The output of the auxiliary decision-making model is verified according to the preset constraint verification rules; The outputs that pass the verification are written back to the structured event sequence, and the initial labels and initial title levels of the corresponding structured events are updated; for the outputs that fail the verification, the initial labels and initial title levels of the corresponding structured events remain unchanged. Based on the updated initial labels and the updated initial title levels, abnormal candidate segments are re-determined, and the process returns to the step of inputting the abnormal candidate segments and their contexts, the initial labels and initial title levels corresponding to each structural event in the abnormal candidate segments into the auxiliary decision model, until there are no abnormal candidate segments in the structural event sequence. Based on the updated initial tags and the updated initial heading levels, generate the heading roles and heading levels for each paragraph in the document to be processed.
3. The method according to claim 2, characterized in that, The step of verifying the output of the auxiliary judgment model according to the preset constraint verification rules includes: The output of the auxiliary judgment model is subjected to at least one of the following checks: format verification, role validity verification, hierarchy validity verification, number continuity verification, parent-child relationship verification, and local consistency verification. The format verification verifies that the output of the auxiliary judgment model meets a parsable structured format; the role validity verification verifies that the title role output by the auxiliary judgment model belongs to a preset role set; the hierarchy validity verification verifies that the title hierarchy output by the auxiliary judgment model is within a preset hierarchy range; the number continuity verification verifies that the number skeleton corresponding to the structured event judged as a title satisfies the same level, parent-child, or preset jump relationship as the number skeleton of the context structured event; the parent-child relationship verification verifies that lower-level title structured events do not appear in isolation; and the local consistency verification verifies that the title role and title hierarchy of structured events with the same or similar number skeletons within the same abnormal candidate segment are consistent.
4. The method according to claim 1, characterized in that, The step of performing anomaly detection on the structural event sequence based on the initial label and the initial title level to determine anomaly candidate segments includes: When a structural event in the structural event sequence is determined to meet the abnormal triggering condition based on the initial label and the initial title level, the corresponding structural event is identified as the target event, and the target event and its adjacent structural events are merged into the abnormal candidate fragment. The abnormal triggering conditions include at least one of the following conditions: the structural event labeled as the title candidate tag cannot form a valid sibling or parent-child progressive relationship with adjacent structural events according to its numbered skeleton and initial title level; among multiple adjacent structural events with the same or similar numbered skeletons, the initial tag includes at least two of the following: title candidate tag, list candidate tag, and non-structural noise tag; the initial title level of the structural event exceeds a preset maximum level, or a level jump occurs relative to adjacent structural events that cannot be explained by the numbered skeleton; the confidence level of the structural event is lower than a preset threshold.
5. The method according to claim 1, characterized in that, The auxiliary judgment model includes a large language model; the step of inputting the abnormal candidate fragment and its context, the initial label and initial title level corresponding to each structural event in the abnormal candidate fragment into the auxiliary judgment model, and obtaining the title role and title level output by the auxiliary judgment model includes: Based on the paragraph information, initial label, initial title level and number skeleton corresponding to each structural event in the abnormal candidate segment, as well as the preset number of context paragraphs before and after the abnormal candidate segment, and the sample events that match the number skeleton of each structural event in the abnormal candidate segment, auxiliary judgment input data is constructed. The auxiliary judgment input data is input into the large language model to obtain the title role and title level of each structural event in the abnormal candidate fragment output by the large language model.
6. The method according to claim 1, characterized in that, The step of decoding the structure events labeled with the title candidate tags based on the initial tags and the number skeleton of each structure event to obtain the initial title level of the structure events labeled with the title candidate tags includes: If the number skeleton of the structural event and the number skeleton at the top of the stack of the hierarchical state stack corresponding to the document to be processed satisfy the same hierarchical continuity relationship, then the initial title level of the structural event is determined to be the same as the title level at the top of the stack; the hierarchical state stack is used to record the number skeleton and title level of the structural events in the document to be processed that have been identified as titles. If the number skeleton of the structured event is a direct child of the number skeleton at the top of the stack, then the initial title level of the structured event is determined to be one level deeper than the title level at the top of the stack. If the number skeleton of the structured event satisfies the same or child relationship as the structured event at a higher title level, then the title level is determined after the title state stack is rolled back to the higher title level.
7. A document title hierarchy restoration device based on a large model, characterized in that, The device includes: The acquisition module is used to acquire the paragraph sequence of the document to be processed. For the paragraphs in the paragraph sequence that meet the preset structural tendency conditions, structural events are constructed in the order of the paragraphs to obtain a structural event sequence. The structural event is an event that represents the structural tendency of the corresponding paragraph in the document structure. The structural event corresponds to a number skeleton. The number skeleton is a normalized numbering structure abstracted from the paragraph number prefix of the corresponding paragraph. The annotation module is used to input the event features of each of the structural events into the sequence labeling model to obtain the initial label of each structural event and the confidence level corresponding to the initial label; the initial label includes title candidate label, list candidate label and non-structural noise label; The decoding module is used to perform title-level decoding on the structural events marked with the title candidate tags based on the initial tags and the number skeleton of each structural event, so as to obtain the initial title level of the structural events marked with the title candidate tags; The detection module is used to perform anomaly detection on the structured event sequence based on the initial tag and the initial title level, and determine the abnormal candidate segments; the abnormal candidate segments include a set of structured events in the structured event sequence that may have title role and / or title level errors; The generation module is used to input the abnormal candidate fragment and its context, the initial label and initial title level corresponding to each structural event in the abnormal candidate fragment into the auxiliary judgment model to obtain the title role and title level output by the auxiliary judgment model, and to generate the title role and title level of each paragraph in the document to be processed based on the title role and title level output by the auxiliary judgment model; the auxiliary judgment model includes a large language model.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
