A text structured extraction method, system, terminal and medium
By analyzing the target text and splicing index numbers, and fine-tuning the large language model with multiple training data sets, the problem of difficult to deal with complex structural documents in the existing technology is solved, and the accuracy and efficiency improvement of structured extraction is achieved.
Patent Information
- Application Number
- CN202411748540.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-12-02
AI Technical Summary
The prior art is difficult to capture and utilize the relationships and hierarchies between paragraphs when processing documents with complex structures, resulting in low structural quality and accuracy of outputs.
By obtaining the parsed text of the target text, adding an index number and splicing it to form the target spliced text. Use multiple training datasets to fine-tune the preset large language model to generate structured content.
It has achieved the accuracy and efficiency of text structured extraction, revealed the internal hierarchy of text, and enhanced the processing capabilities and wide application of large language models.
Smart Images

Figure CN119202144B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing and information retrieval, and in particular to a text structured extraction method, system, terminal and medium. Background Art
[0002] In the field of natural language processing and information retrieval, existing end-to-end models usually focus on the continuous representation of text and lack explicit modeling of document structure. As a result, when processing documents with complex structures such as academic papers, legal documents or reports, the models often find it difficult to capture and utilize the relationships and hierarchical structures between paragraphs, thus affecting the structured quality and accuracy of the output.
[0003] Based on this, the existing method of outputting structured documents by combining paragraph indexes with end-to-end models generates metadata for documents and combines the metadata with large language models to achieve retrieval and answer generation. Although this method uses document structure metadata to enhance model prompts and improve the model's ability to understand document structure, when processing structured documents such as PDFs, web pages, and PPTs, they tend to be simplified into plain text, which not only easily ignores the structural hierarchy of the document, but also is often limited by the understanding of the context corresponding to the set window size when processing long documents, making the model's understanding of the entire document structure inaccurate and incomplete, resulting in inaccurate output of structured documents. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the object of the present invention is to provide a text structured extraction method, system, terminal and medium, aiming to solve the problem that the methods used to generate structured documents in the prior art have an inaccurate and incomplete understanding of the structure of the entire document, resulting in inaccurate output of the structured document.
[0005] In order to achieve the above object, the present invention provides a first aspect of a text structure extraction method, comprising:
[0006] Obtaining the parsed text of the target text, adding index numbers based on the parsed text and concatenating them to obtain the target concatenated text;
[0007] Obtain multiple training data sets based on multiple texts;
[0008] Fine-tuning a preset large language model using the multiple training data sets to obtain a fine-tuned large language model;
[0009] The target concatenated text is processed by the fine-tuned large language model to generate structured content of the target text.
[0010] Optionally, the obtaining of the parsed text of the target text, adding index numbers based on the parsed text and concatenating the text to obtain the target concatenated text includes:
[0011] Parsing the target text according to a preset text parsing format to obtain a parsed text;
[0012] Obtain each paragraph in the parsed text;
[0013] Add an index number and an identifier to each of the paragraphs respectively, to obtain a number of paragraphs with added index numbers;
[0014] All the paragraphs with added index numbers are spliced together to obtain the target spliced text.
[0015] Optionally, obtaining multiple training data sets according to multiple texts includes:
[0016] Obtaining a concatenated text set according to the multiple texts;
[0017] Based on the concatenated text set, a first training data set is obtained by presetting a first large language model, wherein the first training data set includes a plurality of first training data subsets;
[0018] Obtaining a second training data set based on the concatenated text set and the first training data set through the preset first large language model;
[0019] constructing a first prompt set according to the concatenated text set;
[0020] A third training data set is obtained based on the first prompt set through the preset first large language model.
[0021] Optionally, obtaining a concatenated text set according to the multiple texts includes:
[0022] Obtain an initial text set consisting of multiple texts;
[0023] Adding index numbers and identifiers to each paragraph of each text in the initial text set in sequence and then splicing them to obtain multiple spliced texts;
[0024] The multiple concatenated texts are combined to obtain the concatenated text set.
[0025] Optionally, obtaining a first training data set based on the concatenated text set by presetting a first large language model includes:
[0026] Based on each concatenated text in the concatenated text set, a first title and an index number of the first title are obtained by presetting a first language model;
[0027] Updating the first title of each concatenated text and the index number of the first title to obtain a plurality of first training data subsets;
[0028] A first training data set is obtained according to the multiple first training data subsets.
[0029] Optionally, the first title of each concatenated text and the index number of the first title are updated to obtain a plurality of first training data subsets, including:
[0030] According to the title of each spliced text in the spliced text set and the index number of the title, the first title of each corresponding spliced text and the index number of the first title are matched and modified to obtain the updated title of each spliced text and the corresponding index number;
[0031] According to the updated title of each concatenated text and the corresponding index number, a plurality of first training data subsets are obtained, wherein one first training data subset corresponds to an updated title of the concatenated text and the index number corresponding to the updated title.
[0032] Optionally, obtaining a second training data set based on the concatenated text set and the first training data set through the preset first large language model includes:
[0033] Constructing a second prompt through the first training data set and a preset first prompt template, and obtaining a structured title of each concatenated text based on the second prompt and the first training data set through the preset first language model;
[0034] Based on the concatenated text set, updating the structured title of each concatenated text to obtain a plurality of second training data subsets;
[0035] A second training data set is obtained according to the multiple second training data subsets.
[0036] Optionally, constructing a second prompt through the first training data set and a preset first prompt template, and obtaining a structured title of each concatenated text based on the second prompt and the first training data set through the preset first language model, including:
[0037] Constructing a second prompt by using the updated title of the concatenated text, the index number corresponding to the title and a preset first prompt template;
[0038] Obtain each first training data subset in the first training data set;
[0039] Each of the first training data subsets and the second prompt is passed through the preset first large language model to obtain a structured title of each concatenated text.
[0040] Optionally, based on the concatenated text set, the structured title of each concatenated text is updated to obtain a plurality of second training data subsets, including:
[0041] Matching and modifying the structured title of each corresponding spliced text according to the title of each text in the spliced text set to obtain an updated structured title of each spliced text;
[0042] According to the obtained structured title after each concatenated text is updated, a plurality of second training data subsets are obtained, wherein one second training data subset corresponds to a structured title after each concatenated text is updated.
[0043] Optionally, constructing a first prompt set according to the concatenated text set includes:
[0044] Obtaining an extraction object for each concatenated text in the concatenated text set;
[0045] Constructing a plurality of first prompts according to each of the spliced text extraction objects, each of the spliced texts and a preset second prompt template;
[0046] Based on the plurality of first prompts, a first prompt set is obtained.
[0047] Optionally, obtaining a third training data set based on the first prompt set by using the preset first language model includes:
[0048] Based on each first prompt in the first prompt set, obtaining an index number of each extraction object of each concatenated text through the preset first large language model;
[0049] A third training data set is obtained according to the index number of each extracted object of each concatenated text.
[0050] Optionally, fine-tuning a preset large language model using the multiple training data sets to obtain a fine-tuned large language model includes:
[0051] Based on the first training data set, the second training data set and the third training data set, a preset large language model is trained using a fine-tuning technology to obtain a fine-tuned large language model.
[0052] Optionally, processing the target concatenated text by using the fine-tuned large language model to generate structured content of the target text includes:
[0053] Based on the target concatenated text, a structured title of the target concatenated text is obtained by fine-tuning the large language model;
[0054] constructing a third prompt according to the target spliced text;
[0055] The third prompt is used to fine-tune the large language model to obtain all the extraction objects of the target concatenated text and the index number of each extraction object;
[0056] Processing the target concatenated text, the structured title of the target concatenated text, all extracted objects of the target concatenated text and the index number of each extracted object to obtain a plurality of type key-value pairs;
[0057] Based on all the key-value pairs, the structured content of the target text is generated.
[0058] Optionally, a structured title of the target concatenated text is obtained by fine-tuning a large language model based on the target concatenated text, including:
[0059] According to the target concatenated text, the updated title and the corresponding index number of the target concatenated text are obtained by fine-tuning the large language model;
[0060] Constructing a target second prompt by using the updated title of the target concatenated text, the index number corresponding to the title and a preset first prompt template;
[0061] Based on the updated title of the target concatenated text, the corresponding index number and the target second prompt, the large language model is fine-tuned to obtain the structured title of the target concatenated text.
[0062] Optionally, constructing a third prompt according to the target concatenated text includes:
[0063] A third prompt is constructed according to the target concatenated text, an extracted object of the target concatenated text and a preset third prompt template.
[0064] Optionally, the target concatenated text, the structured title of the target concatenated text, all extracted objects of the target concatenated text and the index number of each extracted object are processed to obtain multiple type key-value pairs, including:
[0065] constructing a first key-value pair based on the identifier of the target concatenated text and the content of the target concatenated text, wherein the identifier of the target concatenated text is used as the key of the first key-value pair, and the content of the target concatenated text is used as the value of the first key-value pair;
[0066] Constructing a second key-value pair based on the identifier of the structured title of the target spliced text and the content of the structured title of the target spliced text, wherein the identifier of the structured title of the target spliced text is used as the key of the second key-value pair, and the content of the structured title of the target spliced text is used as the value of the second key-value pair;
[0067] A third key-value pair is constructed based on all extracted objects of the target concatenated text and the index numbers of all extracted objects, wherein the identifiers of all extracted objects of the target concatenated text are used as the keys of the third key-value pair, and the index numbers of all extracted objects are used as the values of the third key-value pair.
[0068] Optionally, after generating the structured content of the target text based on all the key-value pairs, the following steps are included:
[0069] Traversing the second key-value pair of the target text to obtain a structured title of the target text;
[0070] According to the structured title of the target text, an index number of each title is obtained;
[0071] Based on the value of the third key-value pair, obtain all titles of the target text and corresponding index numbers;
[0072] Calculate the interval value of the index numbers of all two adjacent titles of the same level in all titles of the target text to obtain a set of index numbers of text paragraphs contained in each title;
[0073] Traverse the first key-value pair of the target text to obtain the content of the target concatenated text;
[0074] According to the index number set of the text paragraphs contained in each title, searching the content of each text paragraph contained in each title in the content of the target spliced text;
[0075] Get the annotations for each paragraph of the target text;
[0076] The annotation of each paragraph is added to the content of the corresponding text paragraph of the found target text.
[0077] Optionally, after generating the structured content of the target text based on all the key-value pairs, the following steps are included:
[0078] Asking questions about the target spliced text;
[0079] Constructing a fourth prompt according to the question and the target spliced text;
[0080] Inputting the fourth prompt into the preset first language model to obtain an answer with an index number;
[0081] The content of the target concatenated text is obtained according to the index number of the answer and the first key-value pair of the target concatenated text.
[0082] A second aspect of the present invention provides a text structure extraction system, the system comprising:
[0083] A target concatenated text acquisition module is used to acquire the parsed text of the target text, add index numbers based on the parsed text and concatenate them to obtain the target concatenated text;
[0084] A training data set building module, used for obtaining multiple training data sets according to multiple texts;
[0085] A model training module, used to fine-tune a preset large language model using the multiple training data sets to obtain a fine-tuned large language model;
[0086] The structured content generation module is used to generate structured content of the target text by processing the target concatenated text through the fine-tuned large language model.
[0087] The third aspect of the present invention provides a terminal, which includes a memory, a processor, and a text structured extraction program stored in the memory and executable on the processor, wherein the text structured extraction program implements any one of the steps of the above-mentioned text structured extraction method when executed by the processor.
[0088] A fourth aspect of the present invention provides a computer-readable storage medium, on which a text structured extraction program is stored. When the text structured extraction program is executed by a processor, the steps of any one of the above-mentioned text structured extraction methods are implemented.
[0089] Compared with the prior art, the beneficial effects of this solution are as follows:
[0090] The method of the present invention integrates index numbers into the hierarchical retrieval of texts, so that when performing structured extraction of texts, each paragraph can be marked with a corresponding index number, realizing the conversion of the title structure from flat generation to a hierarchical structure, and improving the retrievability of information and the readability and logic of the text content. By combining element extraction and structured directory, the structured content of the hierarchical target text is generated, the consistency and certainty of the retrieval results and the generated structured directory are ensured from the source, and the redundancy in the retrieval and content generation process can be effectively reduced. By combining paragraph index numbers, two-segment extraction and element extraction, the processing flow of structured documents is optimized, the efficiency and accuracy of long text processing can be improved, its inherent hierarchical structure is revealed, the problem of paragraph index numbers and context integration is effectively solved, and the ability of large language models to process the structured content of target texts and the breadth of practical applications are effectively enhanced. BRIEF DESCRIPTION OF THE DRAWINGS
[0091] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0092] Figure 1 It is a flow chart of the text structure extraction method of the present invention;
[0093] Figure 2 It is a schematic diagram of the text structured extraction system module of the present invention;
[0094] Figure 3 It is a schematic diagram of the terminal structure of the present invention. DETAILED DESCRIPTION
[0095] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.
[0096] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0097] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0098] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0099] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0100] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0101] In the field of natural language processing and information retrieval, end-to-end models have attracted attention for their ability to generate the desired output directly from input data. Existing end-to-end models usually focus on the continuous representation of text, but lack explicit modeling of document structure. This makes it difficult for models to capture and utilize the relationships and hierarchical structures between paragraphs when processing documents with complex structures, such as academic papers, legal documents, or reports, thus affecting the structured quality and accuracy of the output.
[0102] The existing method of outputting structured documents by combining paragraph index numbers with end-to-end models mainly generates metadata for documents and combines the metadata with large language models to achieve retrieval and answer generation. This method attempts to improve the model's processing capabilities for long documents by creating structured metadata for documents, but it still shows certain limitations in practical applications. For example, when performing document question-and-answer tasks, the model is often limited by a fixed context window size and faces the challenge of effectively integrating the retrieved paragraph context. It is difficult to fully grasp the content of long documents, which may make the output lack fluency and logical coherence, affecting the clarity of information expression; when processing structured documents such as PDF, web pages and PPT, it tends to simplify them into plain text, and easily ignores the structured hierarchical relationship of the document; in the information retrieval and question-and-answer generation stages, content redundancy and repetition are often generated, thus affecting the quality and accuracy of the output results.
[0103] Based on the above situation, the present invention proposes a text structured extraction method, which mainly constructs the paragraph index number of the parsed text after parsing the target text, splices the parsed target text with the preset index number of each paragraph in the target text, and obtains the index number text; uses the designed two-segment extraction method to construct the first training data set and the second training data set, and integrates the index number into the hierarchical retrieval, so that when performing structured extraction of the text, each paragraph can be marked with a corresponding index number, realizing the conversion of the title structure from flat generation to hierarchical structure, improving the retrievability of information and the readability and logic of the text content. At the same time, using the designed element extraction method, the element extraction and the structured directory are combined to generate the structured content of the hierarchical target text, which ensures the consistency and certainty of the retrieval results and the generated structured directory from the source, and can effectively reduce the redundancy in the retrieval and content generation process. The method of the present invention combines paragraph index numbering, two-segment extraction and element extraction to optimize the processing flow of structured documents, improve the efficiency and accuracy of long text processing, reveal its inherent hierarchical structure, effectively solve the problem of paragraph index numbering and context integration, and effectively enhance the ability of large language models to process the structured content of target texts and the breadth of practical applications.
[0104] The embodiment of the present invention provides a text structure extraction method, which is deployed on electronic devices such as computers and servers and is applied to the scene of extracting structural information of text files. Specifically, Figure 1 As shown, the steps of the method in this embodiment include:
[0105] Step S100: obtaining the parsed text of the target text, adding index numbers based on the parsed text and splicing, to obtain the target spliced text;
[0106] Specifically, first, one or more single or combined structured documents in the formats of PDF, web pages, PPT, etc. are obtained as target texts, and the content of the target texts is parsed according to a preset text parsing format to obtain parsed texts. For example, according to the structure or processing requirements of the target texts, a text parser such as PDF, Word, HTML, TXT, XML, HDFS, EXCEL, etc. is used to parse the target texts into text content in a corresponding format to obtain parsed texts.
[0107] Then, each paragraph in the parsed text is obtained, and an index number and an identifier are added to each paragraph to obtain a number of paragraphs with added index numbers; all the paragraphs with added index numbers are spliced to obtain the target spliced text, which specifically includes:
[0108] First, according to the format and layout of the target text, determine the delimiters between paragraphs, such as blank lines, line breaks, titles, etc. Use the string processing function or library in the programming language to parse the target text into multiple paragraphs according to the identified delimiters to form a paragraph list. In this embodiment, each paragraph in the target text is regarded as a logical unit. As other implementations, each section in the target text can also be regarded as a logical unit to ensure that each logical unit contains complete and meaningful information, so that the split text can correctly reflect the structure and content of the original target text, and the split text parts are stored in a data structure such as a list or a dictionary. Then, according to the structure or processing requirements of the target text, a unique index number and identifier are preset for each parsed paragraph, wherein the index number can be a number, a string or other unique identifier (such as an ID, a hash value, etc.), and the index number is stored in a data structure such as a list or a dictionary; the identifier is used to segment the paragraph (such as "\n\n"), and can be set at the end or beginning of the paragraph. Traverse the parsed paragraph list, and splice each paragraph content with the corresponding index number and identifier according to the set splicing format to obtain the paragraph with the added index number, such as the specific splicing format is "title content" + "&&&refIds: " + index id + "\n", and other titles are tiled and spliced in sequence. Finally, splice all the paragraphs with added index numbers to obtain the target spliced text, and store the target spliced text in a file or database. The splicing method can be to use the index number as a prefix, suffix, embedded content or as a separate field for splicing. This embodiment does not impose specific restrictions on the splicing method, as long as it can ensure that the content of each paragraph with added index numbers and the index number of each paragraph can be accurately identified.
[0109] Step S200: obtaining multiple training data sets according to multiple texts;
[0110] Specifically, obtain multiple documents in formats such as PDF, web pages, and PPT to build a training data set. The training data set includes enough texts, and the formats of different texts can be the same or different, so that the model can learn the characteristics of the corresponding task.
[0111] Step S300: fine-tuning a preset large language model using the multiple training data sets to obtain a fine-tuned large language model;
[0112] Specifically, a pre-trained large language model is selected as the basis. The model is trained on a large-scale general corpus and has good language understanding and generation capabilities, such as the Qwen-14B base model. The training parameters of the model are configured, including but not limited to the learning rate, batch size, number of training rounds, optimizer, etc. The setting of these parameters will directly affect the training effect and performance of the model. According to the selected preset large language model and training data set, the fine-tuning task is defined, including specifying the input and output format of the model, setting the training target, and determining the evaluation index, and the pre-processed training data set and the configured training parameters are used to perform the fine-tuning process to obtain a fine-tuned large language model, so that the performance of the fine-tuned large language model reaches the expected effect and performance; specifically, the pre-processed training data set is input into the Qwen-14B base model large language model, and the SFT fine-tuning technology is used to train the Qwen-14B base model large language model to obtain a fine-tuned large language model.
[0113] Furthermore, before using the training dataset for fine-tuning, the training dataset is preprocessed, for example, data cleaning (such as removing noise, processing missing values, etc.), data format conversion (such as converting text into a format that the model can process), and possible data enhancement (such as increasing sample diversity through data augmentation technology) to ensure the diversity and availability of data samples in the training dataset.
[0114] Step S400: Processing the target concatenated text through the fine-tuned large language model to generate structured content of the target text.
[0115] Specifically, first, according to the content and requirements of the target spliced text, define the format of the structured content, such as determining which information is extracted as key-value pairs, etc.; and according to the capabilities and characteristics of the fine-tuned large language model, set the information extraction strategy, such as using prompt words, templates or context information to guide the model to extract the required information. Then, the target spliced text is input into the fine-tuned large language model, and according to the format of the structured content and the information extraction strategy set, the fine-tuned large language model is used to deeply parse the content of the target spliced text, thereby outputting the structured content of the target text of the type of key-value pairs, lists, nested dictionaries, etc., and storing the structured content of the target text. The structured content is saved as JSON, XML, CSV and other files, or directly integrated into an application or database. Among them, the fine-tuned large language model refers to a large language model that has the ability to process the structured content of the target text and has been fully trained to accurately identify key information based on prompt words. This embodiment does not specifically limit the type of the fine-tuned large language model. It should be noted that the structured content of the concatenated text in this example represents the structural information of the extracted target concatenated text. The present invention may include titles, keywords, introductions, paragraphs, etc. The form of expression of the structured content is not specifically limited and may be a key-value pair, list, nested dictionary, or other structured or semi-structured forms of expression.
[0116] In this embodiment, by parsing the target text, the understanding of the target text by the large language model can be enhanced. By customizing the index number and concatenating it with the parsed text, the index number is integrated into the model method of paragraph generation, so that when performing text structured extraction, each paragraph can be marked with a corresponding index number, and the key information of the target text pointed to by the extraction prompt can be accurately located; the index number text is parsed using a fine-tuned large language model to accurately and comprehensively understand the structure of the entire text, which can not only ensure that the structured content of the generated target text has good readability and accuracy, but also output the hierarchical structure of the target text while retaining the hierarchical relationship between the paragraphs in the text.
[0117] In a preferred embodiment, obtaining multiple training data sets according to multiple texts in step S200 includes:
[0118] Step S210: obtaining a concatenated text set according to the multiple texts;
[0119] Specifically, an initial text set consisting of multiple texts is obtained; index numbers and identifiers are added to each paragraph of each text in the initial text set in turn, and then spliced to obtain multiple spliced texts, that is, by traversing each paragraph of each text in the initial text set, unique index numbers and identifiers are added to each paragraph in each text in turn, and all paragraphs in each text with added index numbers and identifiers are spliced to obtain multiple spliced texts; all spliced texts are combined to obtain a spliced text set.
[0120] Step S220: obtaining a first training data set based on the concatenated text set by presetting a first large language model, wherein the first training data set includes a plurality of first training data subsets;
[0121] Specifically, the features of each concatenated text in the concatenated text set are extracted using the preset first language model, such as word embedding, syntactic structure, semantic relationship, etc., to obtain the updated concatenated text corresponding to each concatenated text, and each updated concatenated text is divided into different first training data subsets according to the subject, source, time, etc. of the text, and all first training data subsets are combined to obtain the first training data set, so that it can better understand and process text data similar to the concatenated text set. Among them, the preset first language model refers to a large language model that has the ability to process the structured content of the target text and can accurately identify key information based on the prompt words, such as GPT, BERT, T5, etc. This embodiment does not specifically limit the type of the first language model.
[0122] In a preferred embodiment, obtaining a first training data set based on the concatenated text set by presetting a first large language model in step S220 includes:
[0123] Step S221: obtaining the first title and the index number of the first title of each concatenated text by using a preset first language model based on each concatenated text in the concatenated text set;
[0124] Step S222: updating the first title of each concatenated text and the index number of the first title to obtain a plurality of first training data subsets;
[0125] Step S223: Obtain a first training data set according to the multiple first training data subsets.
[0126] Specifically, the title of each spliced text in the spliced text set and the index number of the paragraph corresponding to the title are extracted by presetting the first language model (such as GPT4.0), and the first title and the index number of the first title of each spliced text are obtained, and the first title and the index number of each spliced text are recorded and stored in a data structure such as a list, a dictionary or a database for subsequent use. According to the title of each spliced text in the spliced text set and the index number of the title, the first title and the index number of the first title of each corresponding spliced text are matched and modified. If the first title and the matched index number are the same as the real title and index number of the corresponding spliced text, no modification is required; if the first title and the matched index number are different from the real title and index number of the corresponding spliced text, the original first title and the corresponding index number are retained according to the preset rules, or the modified title and the modified index number are used to obtain the updated title and the corresponding index number of each spliced text. According to the updated title and the corresponding index number of each spliced text, multiple first training data subsets are obtained, wherein each first training data subset corresponds to an updated title of a spliced text and the index number corresponding to the updated title, that is, each spliced text corresponds to a first training data subset. Finally, the first training data subsets corresponding to all spliced texts are combined to obtain the first training data set of the first stage, so that the first training data set can contain the title and index number of each spliced text in the spliced text set, so as to improve the integrity of the first training data set. This embodiment is used to display the tiled structure of the paragraph title through the updated title corresponding to each spliced text and the index number corresponding to the updated title.
[0127] Step S230: obtaining a second training data set based on the concatenated text set and the first training data set through the preset first large language model;
[0128] Specifically, the concatenated text set and the first training data set are used to construct subtask extraction prompts, the subtask extraction prompts are input into the preset first language model to obtain the structured title of each concatenated text, and all the structured titles are used to construct the second training data set of the second stage.
[0129] In a preferred embodiment, the step S230 of obtaining the second training data set based on the concatenated text set and the first training data set by using the preset first large language model includes:
[0130] Step S231: construct a second prompt through the first training data set and a preset first prompt template, and obtain a structured title of each concatenated text based on the second prompt and the first training data set through the preset first language model;
[0131] Step S232: Based on the concatenated text set, updating the structured title of each concatenated text to obtain a plurality of second training data subsets;
[0132] Step S233: Obtain a second training data set according to the multiple second training data subsets.
[0133] Specifically, the first training data set and the preset first prompt template are spliced to obtain the second prompt, that is, the updated title of the spliced text, the index number corresponding to the title and the preset first prompt template are spliced to construct the second prompt, wherein the preset first prompt template is used to extract the first training data set, and the second prompt is used to obtain the structured title of each spliced text; each first training data subset in the first training data set is obtained, that is, the updated title corresponding to a single spliced text and the index number corresponding to the updated title; each first training data subset and the second prompt are input into the preset first large language model (such as GPT4.0) for processing to obtain the structured title of each spliced text, so as to update the structured title of each spliced text, thereby obtaining multiple second training data subsets. Wherein, each second training data subset corresponds to an updated structured title of a spliced text.
[0134] Then, the updated structured title of each corresponding spliced text is matched and modified according to the title of each text in the spliced text set. If the updated structured title is the same as the real structured title of the corresponding spliced text, no modification is required; if the updated structured title is different from the real structured title of the corresponding spliced text, the real structured title is retained according to the preset rules, or the modified structured title is adopted to obtain the updated structured title of each spliced text. According to the obtained updated structured title of each spliced text, multiple second training data subsets are obtained, wherein each second training data subset corresponds to an updated structured title of a spliced text.
[0135] It should be noted that the structured content of the concatenated text in this embodiment represents the structural information of the extracted target text. The present invention does not impose any specific restrictions on the form of expression of the structured content of the extracted target text, which may be a key-value pair, a list, a nested dictionary, or other structured or semi-structured forms of expression.
[0136] The above-mentioned steps S220 and S230 constitute a step of performing structured extraction on the spliced text set in the form of a two-stage extraction. In the first stage of the two-stage extraction, the title of each paragraph in each spliced text in the spliced text set and the corresponding index number are used to construct a first training data set to display the flat structure of the paragraph titles in the spliced text; in the first stage of the two-stage extraction, the structured title of the spliced text is obtained by using the first training data set and the subtask extraction prompts, thereby constructing a second training data set to display the hierarchical structure of the paragraph titles in the spliced text.
[0137] Step S240: constructing a first prompt set according to the concatenated text set;
[0138] Specifically, the extraction object of each spliced text in the spliced text set is obtained; multiple first prompts are constructed according to each spliced text extraction object, each spliced text and a preset second prompt template, and a first prompt set is obtained based on multiple first prompts, wherein the first prompt is used to guide the fine-tuned large language model to accurately identify and extract the key information in the required target text, that is, output the index number of the extraction object. The extraction objects include titles, Chinese and English keywords, Chinese and English abstracts, introductions, acknowledgments, references and paragraphs, etc.; the first prompt is used to guide the fine-tuned large language model to extract the index number of the extraction object in the spliced text with index numbers.
[0139] Step S250: Obtain a third training data set based on the first prompt set through the preset first large language model.
[0140] Specifically, based on each first prompt in the first prompt set, each concatenated text is input into a preset first large language model for deep parsing, thereby obtaining an index number of each extracted object of each concatenated text; and a third training data set is obtained according to the index number of each extracted object of each concatenated text. Furthermore, the index numbers of the concatenated texts can be stored in a data structure such as a list or a dictionary.
[0141] For example, a unique index number is defined for each paragraph in the concatenated text, so that the paragraph and the index number have a one-to-one mapping relationship. Specifically, for each concatenated text, the custom index number (0, 1, 2, 3, etc.) and the line break (such as "\n\n") are concatenated into the content of the corresponding paragraph of the concatenated text, that is, in the file storage, the content of each paragraph and the corresponding index number are stored in JSON format. The expression in the large language model is defined as: "text paragraph content" + "&&&refIds:" + index number ID + "\n\n" as a prompt, which is input into the first large language model for subsequent reasoning of various tasks, and the concatenated text after the fusion of the index number is output.
[0142] In this embodiment, a novel two-stage extraction method is designed. By constructing two-stage extraction prompt words, the large language model is guided to progressively extract the structured information in the spliced text with index numbers, which can significantly improve the structural processing ability of the text content. Compared with the traditional text segmentation method, the present invention can more accurately identify and construct the title structure of the text and generate more accurate hierarchical format data. At the same time, by setting the first prompt, the accuracy and efficiency of extracting the key structural element information (such as the extraction object) in the spliced text with index numbers can be effectively improved; and the extracted text elements with index numbers and the hierarchical structure of the title with index numbers are merged to ensure the integrity and accuracy of the structured content of the generated target text. Compared with the traditional single-task extraction, the present invention can more comprehensively identify and extract the key elements of the text, such as titles, keywords, abstracts, etc., and can reversely locate the original text, thereby enhancing the practicality of the extraction results.
[0143] In a preferred embodiment, the step S300 of fine-tuning a preset large language model using the multiple training data sets to obtain a fine-tuned large language model includes:
[0144] Based on the first training data set, the second training data set and the third training data set, a preset large language model is trained using a fine-tuning technology to obtain a fine-tuned large language model.
[0145] Specifically, the first training data set, the second training data set, and the third training data set are input into a preset large language model (such as a Qwen-14B base model), and a fine-tuning technique (such as supervised fine-tuning (SPF) technique) is used to train the preset large language model to obtain a fine-tuned large language model, that is, a pre-trained preset large language model is adjusted using labeled data to make it more suitable for text structured extraction tasks for subsequent online reasoning tasks. Until the preset number of iterations or loss accuracy is reached, a fine-tuned large language model is obtained for subsequent online reasoning tasks. Usually, the pre-training of a large language model is unsupervised, but the fine-tuning process is often supervised. After supervised fine-tuning, the first large language model copies all model designs and their parameters except the output layer, and these model parameters contain the knowledge learned using the data set. Since supervised fine-tuning can use the parameters and structure of the pre-trained large language model to avoid training the model from scratch, it is beneficial to accelerate the training process of the model and can improve the performance of the trained first large language model on the target task.
[0146] In this embodiment, by designing element extraction technology, the index number is integrated into the hierarchical search, and the original text content can be reversely queried from the structured directory, which greatly improves the flexibility and accuracy of the search, and can effectively obtain key information with index numbers, which is conducive to enriching the depth and breadth of the text content. And by establishing a close connection between titles and elements, a more accurate and efficient input method can be provided for long text processing of downstream tasks. At the same time, the trained end-to-end large language model can output the title directory structure of the text while retaining its hierarchical relationship.
[0147] In a preferred embodiment, the step S400 of processing the target concatenated text by using the fine-tuned large language model to generate structured content of the target text includes:
[0148] Step S410: obtaining a structured title of the target concatenated text by fine-tuning the large language model based on the target concatenated text;
[0149] Specifically, the target concatenated text is input into the fine-tuned large language model for processing to obtain the updated title and corresponding index number of the target concatenated text; the updated title of the target concatenated text, the index number corresponding to the title and the preset first prompt template are concatenated to construct the target second prompt; based on the updated title of the target concatenated text, the corresponding index number and the target second prompt, the structured title of the target concatenated text is obtained by fine-tuning the large language model. Among them, the first prompt template is used to extract the updated title of the target concatenated text in the first training data set and the index number corresponding to the updated title, so that the fine-tuned large language model can extract the structured title of the target concatenated text more accurately according to the target second prompt.
[0150] Step S420: constructing a third prompt according to the target concatenated text;
[0151] Specifically, the target concatenated text, the extracted object of the target concatenated text and the preset third prompt template are concatenated to construct the third prompt, that is, the third prompt is constructed according to the content of the target concatenated text and the extracted object of the target concatenated text using the preset third prompt template. The third prompt template is used to define the rules for prompting, so that the fine-tuned large language model can extract the extracted object of the target concatenated text and the index number of each extracted object more accurately according to the target third prompt.
[0152] Step S430: fine-tuning the large language model with the third prompt to obtain all the extraction objects of the target concatenated text and the index number of each extraction object;
[0153] Specifically, the target concatenated text is extracted according to the third prompt using the fine-tuned large language model to obtain all extracted objects of the target concatenated text and the index number of each extracted object.
[0154] Step S440: Processing the target concatenated text, the structured title of the target concatenated text, all extracted objects of the target concatenated text and the index number of each extracted object to obtain a plurality of type key-value pairs;
[0155] Specifically, a first key-value pair is constructed based on the identifier of the target spliced text and the content of the target spliced text, wherein the identifier of the target spliced text is used as the key of the first key-value pair, and the content of the target spliced text is used as the value of the first key-value pair, that is, the content and identifier of each target spliced text constitute a first key-value pair; a second key-value pair is constructed based on the identifier of the structured title of the target spliced text and the content of the structured title of the target spliced text, wherein the identifier of the structured title of the target spliced text is used as the key of the second key-value pair, and the content of the structured title of the target spliced text is used as the value of the second key-value pair, that is, the identifier and content of the structured title of each target spliced text constitute a second key-value pair; a third key-value pair is constructed based on all extracted objects of the target spliced text and the index numbers of all extracted objects, wherein the identifiers of all extracted objects of the target spliced text are used as the keys of the third key-value pair, and the index numbers of all extracted objects are used as the values of the third key-value pair, that is, the identifier and index number of each extracted object of the target spliced text construct a third key-value pair. The key type of the three types of key-value pairs constructed in this embodiment is a dictionary, which is used to represent different structured contents of the target text. It is easy to understand that if the prompt for extracting the elements of the text changes, or the format of the index number text changes, the storage format of the generated structured content of the target text may also change accordingly.
[0156] Step S450: Generate structured content of the target text based on all the key-value pairs.
[0157] Specifically, based on all the first key-value pairs, the second key-value pairs, and the third key-value pairs, the structured content of the target text is generated to represent the complete structured content corresponding to the target text.
[0158] In this embodiment, by constructing the structured content of the target text in the form of key-value pairs and performing hierarchical processing of the text with indexed titles, the title directory structure of the text can be output, revealing its internal hierarchical structure, ensuring the consistency and certainty of the retrieval results and the generated structured directory from the source, and effectively solving the redundancy problem.
[0159] In a preferred embodiment, after generating the structured content of the target text based on all the key-value pairs in step S450, the following steps are included:
[0160] Traverse the second key-value pair of the target text, that is, traverse the identifier and content of the structured title of the target text, and obtain the structured title of the target text; according to the structured title of the target text, obtain the index number corresponding to each title; based on the value of the third key-value pair, that is, extract the index number of the object, obtain all the titles of the target text and the corresponding index number. It can be seen that this embodiment uses the corresponding relationship between the structured title and the index number, and the corresponding relationship between the index number and the title, and uses the second key value and the third key value pair as a bridge to conveniently and efficiently establish the mapping relationship between the structured title of the target text and the real title. If there are two adjacent titles of the same level, the interval value of the index numbers of all two adjacent titles of the same level in all titles of the target text is calculated to obtain the index number set of the text paragraphs contained in each title. The content of the target spliced text is obtained by traversing the first key-value pair of the target spliced text, that is, traversing the content and identifier of each target text; according to the index number set of the text paragraphs contained in each title, the content of each text paragraph contained in each title is searched in the content of the target spliced text; the annotation of each paragraph of the target text is obtained; and the annotation of each paragraph is added to the content of the corresponding text paragraph of the found target text. In this embodiment, the corresponding relationship between the structured title, index number and content of the target text is constructed using the first key-value pair, the second key value and the third key value, which can ensure that the annotation of each paragraph is correctly added to its corresponding text paragraph.
[0161] Demonstration example 1 for actual application scenarios: if the application scenario is a situation where annotations or the like need to be displayed relying on the target text, then the target document uploaded by the user is obtained, the second key-value pair of the target document is traversed, and the index number corresponding to each title is obtained; based on the value of the third key-value pair, that is, the index number of the extracted object, all titles of the target text and the corresponding index numbers are obtained; for two adjacent titles of the same level, the interval value of the index numbers of the adjacent titles of the same level is first calculated to obtain a set of paragraph index number values for titles of that level; the content of the target concatenated text is obtained by traversing the first key-value pair of the target concatenated text, that is, traversing the content and identifier of each target text; according to the set of paragraph index number values of a certain level of title, the text content corresponding to the paragraph is searched in the content of the index number text; the annotations of each paragraph of the target document are obtained; the annotations of each paragraph of the target document are inserted into the text content corresponding to the paragraph, and converted into text formats such as PDF or Word for display.
[0162] In a preferred embodiment, after generating the structured content of the target text based on all the key-value pairs in step S450, the following steps are included:
[0163] Ask questions about the target concatenated text; construct a fourth prompt based on the question and the target concatenated text; input the fourth prompt into a preset first language model to obtain an answer with an index number; and obtain the content of the target concatenated text based on the index number of the answer and the first key-value pair of the target concatenated text.
[0164] Specifically, questions are asked about the content of the target spliced text; a fourth prompt is constructed based on the questions asked and the content of the target spliced text, and the fourth prompt is used to combine the key points of the question and the relevant information in the target spliced text; the fourth prompt is input into the preset first language model for information extraction to obtain an answer with an index number; the content of the target spliced text is obtained based on the target spliced text content and identifier corresponding to the index number of the answer and the first key-value pair of the target spliced text.
[0165] For exemplary example 2 of an actual application scenario, if the application scenario is a paper question-and-answer scenario, the exemplary steps for outputting answer results with index numbers are as follows: the user uploads the target document, first reads the content of the target document, and then sequentially inserts the index number and line break at the end of each paragraph of the target document to obtain a target concatenated text; the user asks questions based on the content of the target concatenated text; the user's question and the target concatenated text are constructed into prompt words and input into the preset first language model to obtain an answer result with an index number; and the text content corresponding to the paragraph is searched in the target concatenated text according to the index number of the answer result.
[0166] The question-and-answer solution of this embodiment is used in common question-and-answer scenarios. It generates prompts based on the structured content of the target text and questions related to the current target text, thereby using the prompt words to guide the trained large language model to output accurate answer results with index numbers. The question-and-answer implementation process is simple and efficient, which is conducive to improving the user experience.
[0167] like Figure 2 As shown, corresponding to the above-mentioned text structured extraction method, an embodiment of the present invention further provides a text structured extraction system, and the above-mentioned text structured extraction system includes:
[0168] A target concatenated text acquisition module 210 is used to acquire the parsed text of the target text, add index numbers based on the parsed text and concatenate them to obtain the target concatenated text;
[0169] A training data set construction module 220, used to obtain multiple training data sets according to multiple texts;
[0170] A model training module 230, configured to fine-tune a preset large language model using the multiple training data sets to obtain a fine-tuned large language model;
[0171] The structured content generation module 240 is used to generate structured content of the target text by processing the target concatenated text through the fine-tuned large language model.
[0172] Specifically, in this embodiment, the specific functions of the above-mentioned text structured extraction system can also refer to the corresponding description in the above-mentioned text structured extraction method, which will not be repeated here.
[0173] Based on the above embodiment, the present invention further provides a terminal, whose principle block diagram can be shown as follows: Figure 3 As shown. The terminal includes a processor, a memory, a network interface and a display screen connected via a system bus. The processor of the terminal is used to provide computing and control capabilities. The memory of the terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a text structured extraction program. The internal memory provides an environment for the operation of the operating system and the text structured extraction program in the non-volatile storage medium. The network interface of the terminal is used to communicate with an external terminal via a network connection. When the text structured extraction program is executed by the processor, the steps of any of the above-mentioned text structured extraction methods are implemented. The display screen of the terminal can be a liquid crystal display screen or an electronic ink display screen.
[0174] Those skilled in the art will understand that Figure 3 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal to which the scheme of the present invention is applied. The specific terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0175] In one embodiment, a terminal is provided, which includes a memory, a processor, and a text structured extraction program stored in the memory and executable on the processor. When the text structured extraction program is executed by the processor, the steps of any one of the text structured extraction methods provided in the embodiments of the present invention are implemented.
[0176] An embodiment of the present invention further provides a computer-readable storage medium, on which a text structured extraction program is stored. When the text structured extraction program is executed by a processor, the steps of any one of the text structured extraction methods provided in the embodiment of the present invention are implemented.
[0177] It should be understood that the serial numbers of the steps in the above embodiments do not imply a sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0178] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0179] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0180] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0181] In the embodiments provided by the present invention, it should be understood that the disclosed apparatus / terminal equipment and method can be implemented in other ways. For example, the apparatus / terminal equipment embodiments described above are only illustrative, for example, the division of the above modules or units is only a logical function division, and in actual implementation, other division methods can be used, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0182] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, it should be understood by those skilled in the art that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features therein may be replaced by equivalents. However, these modifications or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. A text structured extraction method, characterized in that: The following steps are involved: Obtaining the parsed text of the target text, adding index numbers based on the parsed text and concatenating them to obtain the target concatenated text; Obtain multiple training data sets based on multiple texts; Fine-tuning a preset large language model using the multiple training data sets to obtain a fine-tuned large language model; Processing the target concatenated text through the fine-tuned large language model to generate structured content of the target text; The step of obtaining multiple training data sets according to multiple texts includes: Obtaining a concatenated text set according to the multiple texts; Based on the concatenated text set, a first training data set is obtained by presetting a first large language model, wherein the first training data set includes a plurality of first training data subsets; Obtaining a second training data set based on the concatenated text set and the first training data set through the preset first large language model; constructing a first prompt set according to the concatenated text set; Based on the first prompt set, a third training data set is obtained by using the preset first language model; The step of obtaining a first training data set based on the concatenated text set by presetting a first large language model includes: Based on each concatenated text in the concatenated text set, a first title and an index number of the first title are obtained by presetting a first language model; Updating the first title of each concatenated text and the index number of the first title to obtain a plurality of first training data subsets; Obtaining a first training data set according to the multiple first training data subsets; The target concatenated text is processed by the fine-tuned large language model to generate structured content of the target text, including: Based on the target concatenated text, a structured title of the target concatenated text is obtained by fine-tuning the large language model; constructing a third prompt according to the target spliced text; The third prompt is used to fine-tune the large language model to obtain all the extraction objects of the target concatenated text and the index number of each extraction object; Processing the target concatenated text, the structured title of the target concatenated text, all extracted objects of the target concatenated text and the index number of each extracted object to obtain a plurality of type key-value pairs; Based on all the key-value pairs, generate structured content of the target text; The target concatenated text, the structured title of the target concatenated text, all the extracted objects of the target concatenated text and the index number of each extracted object are processed to obtain multiple type key-value pairs, including: constructing a first key-value pair based on the identifier of the target concatenated text and the content of the target concatenated text, wherein the identifier of the target concatenated text is used as the key of the first key-value pair, and the content of the target concatenated text is used as the value of the first key-value pair; Constructing a second key-value pair based on the identifier of the structured title of the target spliced text and the content of the structured title of the target spliced text, wherein the identifier of the structured title of the target spliced text is used as the key of the second key-value pair, and the content of the structured title of the target spliced text is used as the value of the second key-value pair; A third key-value pair is constructed based on all extracted objects of the target concatenated text and the index numbers of all extracted objects, wherein the identifiers of all extracted objects of the target concatenated text are used as the keys of the third key-value pair, and the index numbers of all extracted objects are used as the values of the third key-value pair.
2. The text structure extraction method according to claim 1, characterized in that: The step of obtaining the parsed text of the target text, adding index numbers based on the parsed text and splicing the text to obtain the target spliced text includes: Parsing the target text according to a preset text parsing format to obtain a parsed text; Obtain each paragraph in the parsed text; Add an index number and an identifier to each of the paragraphs respectively, to obtain a number of paragraphs with added index numbers; All the paragraphs with added index numbers are spliced together to obtain the target spliced text.
3. The text structure extraction method according to claim 1, characterized in that: The step of obtaining a concatenated text set according to the multiple texts includes: Obtain an initial text set consisting of multiple texts; Adding index numbers and identifiers to each paragraph of each text in the initial text set in sequence and then splicing them to obtain multiple spliced texts; The multiple concatenated texts are combined to obtain the concatenated text set.
4. The text structure extraction method according to claim 1, characterized in that: The first title of each concatenated text and the index number of the first title are updated to obtain a plurality of first training data subsets, including: According to the title of each spliced text in the spliced text set and the index number of the title, the first title of each corresponding spliced text and the index number of the first title are matched and modified to obtain the updated title of each spliced text and the corresponding index number; According to the updated title of each concatenated text and the corresponding index number, a plurality of first training data subsets are obtained, wherein one first training data subset corresponds to an updated title of a concatenated text and the index number corresponding to the updated title.
5. The text structure extraction method according to claim 1, characterized in that: Based on the concatenated text set and the first training data set, a second training data set is obtained by using the preset first language model, including: Constructing a second prompt through the first training data set and a preset first prompt template, and obtaining a structured title of each concatenated text based on the second prompt and the first training data set through the preset first language model; Based on the concatenated text set, updating the structured title of each concatenated text to obtain a plurality of second training data subsets; A second training data set is obtained according to the multiple second training data subsets.
6. The text structure extraction method according to claim 5, characterized in that: The second prompt is constructed by using the first training data set and a preset first prompt template, and a structured title of each concatenated text is obtained based on the second prompt and the first training data set through the preset first language model, including: Constructing a second prompt by using the updated title of the concatenated text, the index number corresponding to the title and a preset first prompt template; Obtain each first training data subset in the first training data set; Each of the first training data subsets and the second prompt is passed through the preset first large language model to obtain a structured title of each concatenated text.
7. The text structure extraction method according to claim 5, characterized in that: Based on the concatenated text set, the structured title of each concatenated text is updated to obtain a plurality of second training data subsets, including: Matching and modifying the structured title of each corresponding spliced text according to the title of each text in the spliced text set to obtain an updated structured title of each spliced text; According to the obtained structured title after each concatenated text is updated, a plurality of second training data subsets are obtained, wherein one second training data subset corresponds to a structured title after each concatenated text is updated.
8. The text structure extraction method according to claim 1, characterized in that: Constructing a first prompt set according to the concatenated text set includes: Obtaining an extraction object for each concatenated text in the concatenated text set; Constructing a plurality of first prompts according to the extraction object of each concatenated text, each concatenated text and a preset second prompt template; Based on the plurality of first prompts, a first prompt set is obtained.
9. The text structure extraction method according to claim 1, characterized in that: Based on the first prompt set, a third training data set is obtained by using the preset first language model, including: Based on each first prompt in the first prompt set, obtaining an index number of each extraction object of each concatenated text through the preset first large language model; A third training data set is obtained according to the index number of each extracted object of each concatenated text.
10. The text structure extraction method according to any one of claims 1 to 9, characterized in that: The method of fine-tuning a preset large language model using the multiple training data sets to obtain a fine-tuned large language model includes: Based on the first training data set, the second training data set and the third training data set, a preset large language model is trained using a fine-tuning technology to obtain a fine-tuned large language model.
11. The text structure extraction method according to claim 1, characterized in that: Based on the target concatenated text, a structured title of the target concatenated text is obtained by fine-tuning the large language model, including: According to the target concatenated text, the updated title and the corresponding index number of the target concatenated text are obtained by fine-tuning the large language model; Constructing a target second prompt by using the updated title of the target concatenated text, the index number corresponding to the title and a preset first prompt template; Based on the updated title of the target concatenated text, the corresponding index number and the target second prompt, the large language model is fine-tuned to obtain the structured title of the target concatenated text.
12. The text structure extraction method according to claim 1, characterized in that: Constructing a third prompt according to the target splicing text, including: A third prompt is constructed according to the target concatenated text, an extracted object of the target concatenated text and a preset third prompt template.
13. The text structure extraction method according to claim 1, characterized in that: After generating the structured content of the target text based on all the key-value pairs, the method includes: Traversing the second key-value pair of the target text to obtain a structured title of the target text; According to the structured title of the target text, an index number of each title is obtained; Based on the value of the third key-value pair, obtain all titles of the target text and corresponding index numbers; Calculate the interval value of the index numbers of all two adjacent titles of the same level in all titles of the target text to obtain a set of index numbers of text paragraphs contained in each title; Traverse the first key-value pair of the target text to obtain the content of the target concatenated text; According to the index number set of the text paragraphs contained in each title, searching the content of each text paragraph contained in each title in the content of the target spliced text; Get the annotations for each paragraph of the target text; The annotation of each paragraph is added to the content of the corresponding text paragraph of the found target text.
14. The text structure extraction method according to claim 1, characterized in that: After generating the structured content of the target text based on all the key-value pairs, the method includes: Asking questions about the target spliced text; Constructing a fourth prompt according to the question and the target spliced text; Inputting the fourth prompt into the preset first language model to obtain an answer with an index number; The content of the target concatenated text is obtained according to the index number of the answer and the first key-value pair of the target concatenated text.
15. A text structured extraction system, characterized in that: The system is applied to implement the steps of the text structure extraction method according to any one of claims 1 to 14, and comprises: A target concatenated text acquisition module is used to acquire the parsed text of the target text, add index numbers based on the parsed text and concatenate them to obtain the target concatenated text; A training data set building module, used for obtaining multiple training data sets according to multiple texts; A model training module, used to fine-tune the preset large language model using the multiple training data sets to obtain a fine-tuned large language model; The structured content generation module is used to generate structured content of the target text by processing the target concatenated text through the fine-tuned large language model.
16. A terminal, characterized in that: The terminal includes a memory, a processor, and a text structure extraction program stored in the memory and executable on the processor. When the text structure extraction program is executed by the processor, the steps of the text structure extraction method according to any one of claims 1 to 14 are implemented.
17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a text structure extraction program, and when the text structure extraction program is executed by a processor, the steps of the text structure extraction method according to any one of claims 1 to 14 are implemented.
Citation Information
Patent Citations
Information analysis method and device, electronic equipment and computer readable storage medium
CN113032520A
Ultra-long text abstract generation method and device, equipment and medium
CN118779445A