Question and answer corpus generation method and device and related equipment
By using hierarchical heading segmentation and dynamic summarization techniques, combined with a large language model and prompt word templates, the problems of low efficiency and difficulty in guaranteeing the quality of existing question-and-answer corpus generation are solved, and efficient and accurate question-and-answer corpus generation is achieved.
Patent Information
- Application Number
- CN202511108012.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-07
- Publication Date
- 2025-11-21
AI Technical Summary
Existing question-and-answer corpus generation methods rely on manual compilation, which is inefficient, difficult to guarantee quality, and results in insufficient retrieval accuracy.
By acquiring the hierarchical headings and text content of the target document, the text is segmented, and a question allocation strategy is determined based on the hierarchical heading levels and text content. A large language model is used to generate a question-and-answer corpus, and a question list is extracted by combining prompt word templates.
It improved the efficiency and quality of question-and-answer corpus generation, enhanced the relevance and coverage of questions and text, and significantly improved the coverage and accuracy of the generated question-and-answer corpus.
Smart Images

Figure CN120996031A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of natural language processing, and particularly relates to a question-answer corpus generation method and device and related equipment. BACKGROUND
[0002] Retrieval-Augmented Generation (RAG) is a technical framework combining information retrieval and generative AI. The core process is: first, a retriever is used to quickly retrieve document fragments related to the user query from a knowledge base; then, these document fragments are input as context into a large language model (LLM); finally, the LLM generates high-quality answers in combination with the retrieved context information.
[0003] In terms of knowledge base construction, the traditional approach is usually to directly import original structured documents. However, when the retriever retrieves based on such original structured documents, the retrieval accuracy is often low. Therefore, an improved solution is to construct a question-answer corpus dataset as a knowledge base based on structured documents to improve retrieval accuracy. However, the generation of such question-answer corpus currently mainly relies on manual sorting, which has the problems of low efficiency and difficult to guarantee quality.
[0004] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present disclosure, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0005] The present disclosure provides a question-answer corpus generation method, device and related equipment, which can improve the generation efficiency and quality of question-answer corpus.
[0006] Other characteristics and advantages of the present disclosure will become apparent from the following detailed description, or will be learned by practice of the present disclosure.
[0007] According to one aspect of the present disclosure, a question-answer corpus generation method is provided, the method comprising: obtaining a target document, the target document comprising a plurality of hierarchical titles and text content corresponding to each hierarchical title; performing text blocking on the target document according to the plurality of hierarchical titles and the text content corresponding to each hierarchical title, to obtain a plurality of text blocks; determining a question assignment strategy for each text block based on a hierarchical title level of the text block and text content of the text block; extracting a question list from the each text block based on the question assignment strategy and a prompt word template; and generating a question-answer corpus by using a large language model to answer questions in the question list.
[0008] In some embodiments, the text chunking of the target document according to the plurality of hierarchical titles and the text content corresponding to each hierarchical title comprises: constructing a tree structure based on the plurality of hierarchical title levels; generating a plurality of initial text blocks corresponding to the hierarchical titles from the lowest level to the highest level by level-up backtracking based on the tree structure, wherein each initial text block in the plurality of initial text blocks comprises text content corresponding to the hierarchical title level of the initial text block; and performing dynamic chunking summarization on the text content of each initial text block in the plurality of initial text blocks to obtain a plurality of text blocks.
[0009] In some embodiments, when the text content of the initial text block does not include a next hierarchical title, the dynamic chunking summarization of the text content corresponding to each initial text block in the plurality of initial text blocks to obtain a plurality of text blocks comprises: determining the text length of the initial text block according to the text content corresponding to each initial text block; determining whether the text length is greater than the maximum context length supported by the large language model; if yes, cutting the text content corresponding to the initial text block into a plurality of text slices, and inputting the plurality of text slices into the large language model to output the summarization result as a text block; wherein adjacent text slices in the plurality of text slices have a preset text length of overlapping text content; and if no, taking the text content corresponding to the initial text block as a text block.
[0010] In some embodiments, when the text content of the initial text block includes a next hierarchical title, the dynamic chunking summarization of the text content corresponding to each initial text block in the plurality of initial text blocks to obtain a plurality of text blocks comprises: determining the text length of the initial text block according to the text content corresponding to each initial text block; determining whether the text length is greater than the maximum context length supported by the large language model; if yes, according to the proportion of the text length of the text content corresponding to the next hierarchical title in the total text length of the initial text block, assigning a summarization length proportion, and using the large language model to summarize the text content corresponding to the next hierarchical title according to the summarization length proportion, and then merging to output the summarization result as a text block; and if no, taking the text content corresponding to the initial text block as a text block.
[0011] In some embodiments, the determining, based on the hierarchical title level of each text block and the text content of each text block, a question distribution strategy of each text block, comprises: determining, based on the hierarchical title level of each text block and a mapping relationship of a hierarchical question distribution matrix, a question type of each text block and a weight of the question type, wherein the hierarchical question distribution matrix comprises a question type corresponding to each title level and a weight of the question type; determining, according to the text content of each text block and the weight of the question type, a question quantity of each text block; and determining, according to the question type of each text block and the question quantity, the question distribution strategy of each text block.
[0012] In some embodiments, the determining, according to the text content of each text block and the weight of the question type, a question quantity of each text block, comprises: determining, according to a text length of the text content of each text block and a preset threshold, a total question quantity of each text block; determining, according to the total question quantity of each text block and the weight of the question type, a quantity of each question type; and determining, according to the quantity of each question type, the question quantity of each text block.
[0013] In some embodiments, the method further comprises: constructing a prompt component library and a prompt template containing a placeholder; and the extracting, based on the question distribution strategy and the prompt template, a question list from each text block, comprises: matching, based on the question distribution strategy, a target component from the prompt component library; filling the target component into the placeholder of the prompt template to generate a prompt; and inputting the prompt into a large language model to extract a question list from each text block.
[0014] According to another aspect of the present disclosure, there is also provided a question and answer corpus generation apparatus, comprising: an acquisition module configured to acquire a target document, the target document comprising a plurality of hierarchical titles and text content corresponding to each hierarchical title; a text blocking module configured to perform text blocking on the target document according to the plurality of hierarchical titles and the text content corresponding to each hierarchical title to obtain a plurality of text blocks; a question distribution strategy determination module configured to determine, based on a hierarchical title level of each text block and text content of each text block, a question distribution strategy of each text block; a question extraction module configured to extract, based on the question distribution strategy and a prompt template, a question list from each text block; and a question and answer corpus generation module configured to answer questions in the question list using a large language model to generate a question and answer corpus.
[0015] According to another aspect of the present disclosure, an electronic device is also provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the question and answer corpus generation method of any one of the above via execution of the executable instructions.
[0016] According to another aspect of the present disclosure, a computer readable storage medium having stored thereon a computer program is also provided, the computer program, when executed by a processor, implements the question and answer corpus generation method of any one of the above.
[0017] According to another aspect of the present disclosure, a computer program product is also provided, comprising: a computer program or instructions, which, when executed by a processor, implements the question and answer corpus generation method of any one of the above.
[0018] The question and answer corpus generation method, device and related equipment provided in the embodiments of the present disclosure, the method comprises: obtaining a target document, the target document comprising a plurality of hierarchical titles and text content corresponding to each hierarchical title; performing text blocking on the target document according to the plurality of hierarchical titles and the text content corresponding to each hierarchical title, to obtain a plurality of text blocks; determining a question distribution strategy for each text block based on the hierarchical title level of each text block and the text content of each text block; extracting a question list from each text block based on the question distribution strategy and a prompt word template; and generating a question and answer corpus by using a large language model to answer the questions in the question list. In this embodiment, the document is accurately divided by hierarchical title blocking, the question strategy is dynamically generated in combination with the text block level and content, and the question extraction is standardized with the help of the prompt word template, which significantly improves the relevance and coverage of the questions and the text, and then the large language model is used to batch generate answers, finally the quality of the question and answer corpus is improved in terms of coverage and accuracy, and the generation efficiency of the question and answer corpus is improved.
[0019] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0020] The drawings herein are incorporated into the specification and form part of the specification, show embodiments consistent with the present disclosure, and together with the specification serve to explain the principles of the present disclosure. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor.
[0021] Figure 1 A system structure schematic diagram of a question and answer corpus generation method in an embodiment of the present disclosure is shown;
[0022] Figure 2A flow chart of a method for generating a question-answer corpus is shown in the embodiments of the present disclosure.
[0023] Figure 3 A flow chart of a method for text chunking is shown in the embodiments of the present disclosure.
[0024] Figure 4 A schematic diagram of a text chunk structure is shown in the embodiments of the present disclosure.
[0025] Figure 5 A flow chart of another method for text chunking is shown in the embodiments of the present disclosure.
[0026] Figure 6 A flow chart of another method for text chunking is shown in the embodiments of the present disclosure.
[0027] Figure 7 A flow chart of a method for determining a question distribution strategy is shown in the embodiments of the present disclosure.
[0028] Figure 8 A flow chart of a method for generating a question corpus is shown in the embodiments of the present disclosure.
[0029] Figure 9 A specific question corpus generation system is shown in the embodiments of the present disclosure.
[0030] Figure 10 A schematic diagram of a question-answer corpus generation apparatus is shown in the embodiments of the present disclosure.
[0031] Figure 11 A structural block diagram of an electronic device is shown in the embodiments of the present disclosure. DETAILED DESCRIPTION
[0032] Example implementations will now be described more fully with reference to the accompanying drawings. Example implementations can be implemented in any
[0033] In addition, the accompanying drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the present disclosure and serve to explain the principles of the present disclosure. The same reference numbers in different drawings represent the same or similar elements.
[0034] For ease of understanding, before introducing the embodiments of the present disclosure, several terms involved in the embodiments of the present disclosure are explained as follows:
[0035] Fixed threshold segmentation is a text segmentation method, which refers to dividing the text directly into several equal or approximately equal length segments according to a pre-set fixed standard (such as every 500 words, every 300 characters, etc.). For example: a 1500-word document is divided by 500 words, which will be directly divided into 3 blocks, regardless of chapters or logical pauses. The advantage of fixed threshold segmentation is that it is simple to calculate and efficient, and is suitable for quick preprocessing of structured text (such as legal provisions, news releases), but fixed threshold segmentation does not consider semantic changes of text, and only relies on mechanical rules, so the segmentation result will destroy the semantic coherence.
[0036] Recursive segmentation is a text processing method, which first divides the whole text into large blocks according to the initial threshold, and then repeatedly applies the same rule (such as adjusting the threshold) to each large block for subdivision, forming a multi-level segmentation structure. Recursive segmentation does not rely on document structure, but only divides based on text surface features, so it is difficult to understand complex semantics, especially for structured but semantically implicit documents such as formal documents, the effect is limited.
[0037] The specific implementation of the embodiments of the present disclosure will be described in detail below in conjunction with the drawings.
[0038] Figure 1 An exemplary application system architecture schematic diagram to which the question and answer corpus generation method in the embodiments of the present disclosure can be applied is shown. As shown in Figure 1 The system architecture can include a terminal device 101, a network 102 and a server 103.
[0039] The network 102 is a medium for providing a communication link between the terminal device 101 and the server 103, which can be a wired network or a wireless network.
[0040] Optionally, the wireless or wired networks described above use standard communications technologies and / or protocols. The network can be the Internet, but can also include any combination of LANs, MANs, WANs, mobile, wired, or wireless networks, networks of networks, and / or intranets. In some embodiments, technologies used include, without limitation, Hypertext Markup Language (HTML), Extensible Markup Language (XML), and / or the like, to create and transmit data over the network. In addition, conventional encryption technologies such as the Secure Sockets Layer (SSL), Transport Layer Security (TLS), Virtual Private Networks (VPNs), Internet Protocol Security (IPSec), and / or the like, can be used to encrypt all or some of the links between nodes in the network. In other embodiments, custom and / or proprietary data communications technologies can be used in place of, or in addition to, the above technologies.
[0041] The terminal device 101 can be various electronic devices, including but not limited to a smartphone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a wearable device, an augmented reality device, a virtual reality device, and the like.
[0042] Optionally, the clients of the application programs installed in different terminal devices 101 are the same, or the clients of the same type of application programs based on different operating systems. Based on the difference of terminal platforms, the specific forms of the clients of the application programs can also be different, for example, the application program client can be a mobile phone client, a PC client, and the like.
[0043] The server 103 can be a server that provides various services, for example, a background management server that provides support for the device operated by the user using the terminal device 101. The background management server can analyze and process the received request and the like, and feed back the processing result to the terminal device.
[0044] Optionally, the server can be a stand-alone physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platform.
[0045] Those skilled in the art can know that, Figure 1 The number of terminal devices, networks and servers in the above system architecture is only illustrative, and any number of terminal devices, networks and servers can be provided according to actual needs. The embodiments of the present disclosure do not limit this.
[0046] Under the above system architecture, the present disclosure provides a question and answer corpus generation method, which can be executed by any electronic device with computing processing capability.
[0047] In some embodiments, the question and answer corpus generation method provided in the embodiments of the present disclosure can be executed by the terminal device of the above system architecture; in other embodiments, the question and answer corpus generation method provided in the embodiments of the present disclosure can be executed by the server in the above system architecture; in other embodiments, the question and answer corpus generation method provided in the embodiments of the present disclosure can be realized by the terminal device and the server in the above system architecture through interaction.
[0048] Figure 2 A flow chart of a question and answer corpus generation method in the embodiments of the present disclosure is shown as follows. Figure 2 As shown in the flow chart, the question and answer corpus generation method provided in the embodiments of the present disclosure includes the following steps:
[0049] S202, obtaining a target document.
[0050] In the present embodiment, the target document includes a plurality of hierarchical titles and text content corresponding to each hierarchical title. The hierarchical title refers to a title divided according to logical relationship, such as document title H0, first-level title H1, second-level title H2, third-level title H4 to N-level title HN, etc., which can be distinguished by indentation, font size or numbering, etc. The text content associated under each title matches the title level, such as all text content under the first-level title corresponding to the first-level title, all text content under the third-level title corresponding to the third-level title. It can be understood that all text content under the first-level title can include second-level title, third-level title, etc.
[0051] Specifically, the target document can be a structured document, and specific formats include, for example, Markdown, Docx, and the like. It should be noted that a structured document refers to data organized according to fixed rules, such as a table (Excel), a database record, an XML / JSON file, and the like. The structured document has the characteristics of clear fields and clear levels, and is easy for machines to parse. For example, the target document can specifically refer to structured documents such as enterprise standards, specifications, manuals, and the like in the marketing service domain.
[0052] In S204, the target document is text-blocked according to the plurality of hierarchical titles and the text content corresponding to each hierarchical title, to obtain a plurality of text blocks.
[0053] In this embodiment, text blocking refers to splitting the target document into a plurality of independent text units according to the hierarchical title structure. Each text block starts with a certain hierarchical title and contains all associated text content under the title.
[0054] It should be noted that in the related art, a fixed threshold blocking or recursive blocking is usually used to divide the target document into independent units. The above two methods lack analysis of semantic or grammatical structure, resulting in semantic fragmentation (such as truncated paragraphs). In this embodiment, when the target document is text-blocked according to the plurality of hierarchical titles and the text content corresponding to each hierarchical title, all associated text (including paragraphs, lists, etc.) under each title are combined into a text block starting with the title, the natural association between the title and the content is maintained, the association between the title and the content is avoided, and the plurality of text blocks obtained can retain the information of the structured document.
[0055] In S206, the problem allocation strategy of each text block is determined based on the hierarchical title level of each text block and the text content of each text block.
[0056] In this embodiment, considering the content attribute differences of different hierarchical titles, a problem type subdivision and hierarchical quota binding allocation logic is adopted. For example, for the text block corresponding to the first-level title, macro-cognitive type questions are focused on, in which summary questions account for 40%, the content theme is extracted; comparative questions account for 30%, the competitive dimension is highlighted; trend questions account for 30%, the forward-looking perspective is extended. For the text block of the second-level title, medium-operation type questions are focused on, in which process questions account for 50%, the execution logic is clear; conditional questions account for 30%, the boundary rules are defined; correlation questions account for 20%, the system connection is strengthened. For the text block of the third-level and the last-level title, micro-detail type questions are focused on, in which detail questions account for 50%, the execution accuracy is anchored; terminology explanation type questions account for 30%, the cognitive barriers are eliminated; exception handling type questions account for 20%, special scenarios are covered.
[0057] In some embodiments, if the first-level title text block contains cross-field comparison cases, the proportion of comparative questions can be increased to 40%; if there are dense professional terms in the last-level title text block, the proportion of term explanation type questions can be increased to 40%, ensuring that the question allocation is accurately matched with the content characteristics.
[0058] S208, extracting a question list from each text block based on the question allocation strategy and the prompt word template.
[0059] In the present embodiment, the question allocation strategy refers to pre-set rules or logic, such as question type, question type weight, and question number, to determine how to extract questions from different text blocks. The prompt word template is a pre-set standardized question format, such as “generate x summary questions to cover the entire content or main points or all conclusions of the text block” and “generate x detailed questions based on the content of a certain scene or segment of the text block to ask in-depth and specific questions”, which is used to guide the positioning of questions from the text block. Extracting a question list refers to identifying and outputting questions that meet the requirements from each independent text block according to the above question allocation strategy and template, and finally forming a question list.
[0060] For example, according to the question allocation strategy, the question type and question number of each type of question are determined. Taking the text block with the first-level title level in the structured document “Traffic Package Promotion Plan” as an example, because it contains macro promotion strategy (involving summary) and consideration of market trends (involving trends), the types of questions involved include 60% summary type and 40% trend type, and questions such as “What are the core points of the traffic package promotion plan?” and “What is the impact of the 5G technology popularization trend on the promotion pace of the traffic package?” are extracted according to the proportion. Taking the text block with the third-level title level in “Mobile Phone Repair Service Specification (Appendix)” as an example, because it involves specific operations and professional terms, the types of questions involved include 50% detail type, 30% term explanation type, and 20% exception handling type, and questions such as “What is the specific standard for the thickness of the glue applied in the mobile phone screen replacement operation?” “What does the term ‘mainboard fly line repair’ mean in mobile phone repair?” and “How to handle the situation when the mainboard is severely damaged and cannot be repaired during the mobile phone repair process?” are extracted according to the proportion of detail type, term explanation type, and exception handling type.
[0061] S210, using a large language model to answer the questions in the question list to generate a question and answer corpus.
[0062] In some embodiments, the large language model can also be used to check the answers corresponding to the target document verification questions. For example, the large language model is used to check whether the answer meets the specification requirements of the corresponding question type, and on the other hand to ensure that the answer content is consistent with the text information. If it is found that the answer deviates (such as the answer content exceeds the document range, and is inconsistent with the document information), the correction instruction is automatically triggered. After the verification is passed, the question and answer corpus is integrated according to the allocation proportion of each question type, ensuring that different types of information can be evenly presented, and the key content in the structured document such as the business marketing service field can be comprehensively and accurately reflected, providing high-quality corpus support for subsequent retrieval.
[0063] In the above embodiments, by precisely dividing the document through hierarchical title block, dynamically generating question strategies combining text block level and content, and standardizing question extraction with the help of prompt word templates, the relevance and coverage of questions and text are significantly improved, and then the large language model is used to generate answers in batches, finally realizing the quality improvement of question and answer corpus in coverage and accuracy, and improving the generation efficiency of question and answer corpus.
[0064] In some embodiments, Figure 3 A text block method flowchart is provided for the embodiments of the present disclosure, which combines Figure 3 As shown in the figure, the text block method provided by the embodiments of the present disclosure can include the following steps:
[0065] S302, constructing a tree structure based on the levels of the multiple hierarchical titles.
[0066] In this embodiment, all hierarchical titles and their levels (such as H1, H2, etc. labels or styles) in the target document are first parsed, and then nested layer by layer according to the hierarchical affiliation: high-level titles are used as roots or branch starting points, and low-level titles are mounted as child items in turn, finally forming a tree reflecting the logical framework of the document. For example, the first-level title is the trunk, the second-level title is the branch, and the third-level title is the leaf, which intuitively presents the content hierarchy.
[0067] S304, based on the tree structure, generating multiple initial text blocks corresponding from the last-level title to the highest-level title by level-by-level upward backtracking of the hierarchical title levels.
[0068] In this embodiment, each initial text block contains text content related to its corresponding hierarchical title level. For example, Figure 4As shown in the text block structure diagram, it is assumed that the target document contains five levels of headings, and the fourth level of headings (H4) is taken as the minimum block unit, and each minimum block unit forms a text block, referred to as an H4 text block. The third level of headings (H3) is traced back to the parent node of H4, and the contents corresponding to all H4 headings under the H3 node are integrated into a text block, referred to as an H3 text block. The second level of headings (H2) is traced back to the parent node of H3, and the contents corresponding to all H3 and H4 headings under the H2 node are integrated into a text block, referred to as an H2 text block. The first level of headings (H1) is traced back to the parent node of H2, and the contents corresponding to all H2, H3 and H4 headings under the H1 node are integrated into a text block, referred to as an H1 text block. The entire document is taken as a text block, referred to as an H0 text block. It should be noted that if a branch of the tree structure is missing the fourth level of headings, the minimum block unit of the branch can be set as the third level of headings. Similarly, if a branch is missing the third level of headings, the minimum block unit of the branch can be set as the second level of headings. In this way, the target document is divided into H4, H3, H2, H1 and H0 five kinds of text block units according to the hierarchical headings, and the original text structure relationship is retained.
[0069] In this embodiment, document blocking provides a basis for high-quality question generation, and different levels of text blocks correspond to different question types and weights. The length of the text block affects the calculation of the number of basic questions and is the basis for dynamic quota allocation of questions, so document blocking can optimize the efficiency and quality of question generation.
[0070] In this embodiment, according to the text content in each text block, the text content is summarized by using a large language model, and each summary content is taken as a text block to output a structured text block list. Each entry can include a title level, a title, a text block and a source file. When the text length of a certain level of text block is too long, the contents of its child blocks are summarized and merged in proportion, and the core semantics are retained through recursive processing layer by layer upwards through large model summarization to avoid information loss. Through text blocking and summarization of each text block, the document structure is maintained, the block length is controlled through dynamic summarization, and the context coherence and information integrity are balanced.
[0071] In this embodiment, compared with the traditional method of generating summaries only for a single paragraph or the entire text, the long-distance dependency relationship of the text is lost. In this embodiment, hierarchical blocking and dynamic summarization can accurately divide the document content and retain the semantic association of the title. This not only realizes information aggregation at the whole text level, but also retains the original information at the current level, while compressing redundant information, so that the generated question and answer corpus is more structured and focuses on key content, and the generation efficiency and accuracy of the question and answer corpus are improved.
[0072] In this embodiment, compared with the traditional method of generating summaries only for a single paragraph or the entire text, the long-distance dependency relationship of the text is lost. In this embodiment, hierarchical blocking and dynamic summarization can accurately divide the document content and retain the semantic association of the title. This not only realizes information aggregation at the whole text level, but also retains the original information at the current level, while compressing redundant information, so that the generated question and answer corpus is more structured and focuses on key content, and the generation efficiency and accuracy of the question and answer corpus are improved.
[0073] In some embodiments, when the text content of the initial text block does not include the next level title, Figure 5 A text block method flowchart provided by the embodiments of the present disclosure is shown in Figure 5 As shown in the figure, the text content corresponding to each of the plurality of initial text blocks is dynamically block abstracted to obtain a plurality of text blocks, which can include the following steps:
[0074] S502, determine the text length of the initial text block according to the text content corresponding to each initial text block.
[0075] S504, determine whether the text length is greater than the maximum context length supported by the large language model, if yes, go to step S506; if no, go to step S508.
[0076] In this embodiment, the maximum context length of the large language model refers to the maximum number of characters or tokens that can be processed at a time, which can be denoted as maxLen.
[0077] S506, cut the text content corresponding to the initial text block into a plurality of text slices, and input the plurality of text slices into the large language model, and output the abstract result as a text block.
[0078] In this embodiment, the adjacent text slices in the plurality of text slices have text content overlapping by a preset text length. For example, a character / word threshold (such as 500 words) is first set, and the text block (such as the content under the H4 title) is cut by a sliding window according to this length. The window is moved each time to retain a partial overlap (such as 100 words), avoiding cutting into a complete semantic unit. Then each text slice after cutting is input into the large model to generate a sub-abstract of each text slice, ensuring that each piece of content is compressed and refined. Finally, the sub-abstracts of all text slices are spliced into a final text block, retaining the core information of the original theme while controlling the overall length.
[0079] S508, take the text content corresponding to the initial text block as a text block.
[0080] In this embodiment, compared with the traditional fixed threshold block, the present embodiment avoids information loss or misjudgment caused by fixed threshold block through the fixed threshold and partial overlap, balances the context coherence and information integrity, so that the model can capture more complete semantic relationship, and the generated question logic is more rigorous and more consistent with the original intention, which can improve the quality of the generated question and further improve the quality of the generated question and answer corpus.
[0081] In some embodiments, when the text content of the initial text block includes the next level title, Figure 6 A text block method flowchart provided by the embodiments of the present disclosure is shown inFigure 6 As shown, the embodiment of the present disclosure provides dynamic chunking summary on the text content corresponding to each of the plurality of initial text blocks to obtain a plurality of text blocks, which can include the following steps:
[0082] S602, determining the text length of the initial text block according to the text content corresponding to each initial text block.
[0083] S604, judging whether the text length is greater than the maximum context length supported by the large language model, if yes, going to step S606; if no, going to step S608.
[0084] S606, according to the proportion of the text length of the text content corresponding to the next level title in the initial text block to the total text length of the initial text block, allocating an abstract length proportion, and using the large language model to respectively summarize the text content corresponding to the next level title according to the abstract length proportion, and outputting the summary result as a text block.
[0085] In this embodiment, the total length of the initial text block is first counted, and then the proportion of the text length of the content corresponding to each next level title in the initial text block is calculated, and the target length required for summarizing is allocated according to this proportion. For example, for an H3 text block with a title level of three, the proportion of the text length of the text content under each fourth level title in the H3 text block is calculated; for an H2 text block with a title level of three, the proportion of the text length of the text content under each third level title in the H2 text block is calculated. For the content corresponding to each next level title, a summary can be independently generated by the large language model according to the allocated length, to ensure that the details and omissions of each part of the summary match the length of the original text. The parts of the summary are spliced in the original hierarchical order to form a coherent overall summary, which not only preserves the structure of the original text, but also controls the total length.
[0086] For example, if it is judged that the original text length of the H3 title exceeds maxLen, the proportion of the original text length of each H4 title is taken as the abstract length proportion, and the original text of each H4 title is summarized by the large language model according to the proportion, and finally the summary results are combined as a text block. If it is judged that the original text length of the H2 title exceeds maxLen, the proportion of the original text length of each H3 title is taken as the abstract length proportion, and the original text of each H3 title is summarized by the large language model according to the proportion, and finally the summary results are combined as a text block. If it is judged that the original text length of the H1 title exceeds maxLen, the proportion of the original text length of each H2 title is taken as the abstract length proportion, and the original text of each H2 title is summarized by the large language model according to the proportion, and finally the summary results are combined as a text block. If it is judged that the original text length of the H0 title exceeds maxLen, the proportion of the original text length of each H1 title is taken as the abstract length proportion, and the original text of each H1 title is summarized by the large language model according to the proportion, and finally the summary results are combined as a text block.
[0087] S608, taking the text content corresponding to the initial text block as the text block.
[0088] In the embodiment, when a text block at a certain level is too long, the content of its sub-blocks is proportionally merged to avoid information loss or misjudgment, so that the large language model can capture complete semantic relationships, and the generated question has more rigorous logic and is more consistent with the original intention, which can improve the quality of the generated question and further improve the quality of the generated question-answer corpus.
[0089] In some embodiments, Figure 7 A question distribution strategy determination method flowchart is provided for the embodiments of the present disclosure, which combines Figure 7 As shown in the figure, the embodiments of the present disclosure determine the question distribution strategy of each text block based on the hierarchical title level of each text block and the text content of each text block, which can include the following steps:
[0090] S702, determining the question type and the weight of the question type of each text block based on the mapping relationship between the hierarchical title level of each text block and the hierarchical question distribution matrix.
[0091] In the embodiment, the hierarchical question distribution matrix contains the question type and its weight corresponding to each title level. The mapping relationship refers to associating the hierarchical level (such as first-level and second-level titles) of the text block title with the corresponding question type (such as factual type and analytical type). For example, the first-level title can correspond to macro-analysis questions, and the second-level title can correspond to specific factual questions. The weight matrix assigns importance values to different combinations of title levels and question types, reflecting their priority or impact. For example, the weight of the first-level title + analytical type question is set to 0.8, and the weight of the second-level title + factual type question is set to 0.3. Through the mapping relationship between the hierarchical title level of each text block and the hierarchical question distribution matrix, the matching relationship between each text block and the question requirement can be systematically sorted out to facilitate quick positioning of key points during subsequent auxiliary information retrieval or content generation.
[0092] For example, a mapping relationship matrix of title level and question type and weight can be constructed in advance, such as: H1: summary (60%), comparative analysis (10%), trend (30%); H2: summary (40%), comparative analysis (40%), trend (20%); H3: detail (50%), term explanation (20%), summary (30%); H4: detail (60%), term explanation (40%).
[0093] S704, determining the number of questions for each text block according to the text content of each text block and the weight of the question type.
[0094] In some embodiments, determining the number of questions for each text block according to the text content of each text block and the weight of the question type can specifically include: determining the total number of questions for each text block according to the text length of the text content of each text block and a preset threshold; determining the number of each question type according to the total number of questions for each text block and the weight of the question type; and determining the number of questions for each text block according to the number of each question type.
[0095] For example, if the H1 text block is 20,000 words long, the threshold is set to 3 questions per thousand words, and the total number of questions is 60; if the summary is 60%, the comparative analysis is 10%, and the trend is 30%, then 36 summary questions, 6 comparative analysis questions, and 18 trend questions are allocated.
[0096] In some embodiments, the number of each type of question is calculated, and the Monte Carlo random selection method is used to handle decimals to make the final number of questions an integer while trying to be close to the weight proportion. For example, first, according to the weight of the question type (for example, class A accounts for 30% and class B accounts for 70%), the theoretical value is obtained by multiplying the total number of questions by the weight (for example, 100 questions in total, 30 questions for class A and 70 questions for class B). If the weight calculation result contains a decimal (for example, 30.5 questions for class A), it is determined by random probability whether to round off (for example, with a 50% probability of retaining 0.5, and finally class A may have 30 or 31 questions). After multiple random selections, the actual number of questions will be close to the theoretical weight proportion, avoiding the proportion deviation caused by simple rounding.
[0097] S706, determining a question allocation strategy for each text block according to the question type and the number of questions for each text block.
[0098] In the above embodiments, by accurately matching the title level and the question type, the number of questions is dynamically controlled, and the analysis efficiency and the pertinence are improved.
[0099] In some embodiments, Figure 8 A question corpus generation method flowchart is provided for the embodiments of the present disclosure, and in combination with Figure 8 As shown in the figure, the question and answer corpus generation method provided by the embodiments of the present disclosure can include the following steps:
[0100] S802, constructing a prompt word component library and a prompt word template containing a placeholder.
[0101] In this embodiment, the basic components can be divided by problem categories, each component contains two parts of instruction prefix + parameter constraint. The prompt word template design adopts the "fixed framework + placeholder" structure, and the general template is: "Based on the document "[document name] The content of [text block title], [component placeholder]. The question needs to comply with the telecom business terminology specification, avoid duplication and cover the core information." Among them, [component placeholder] is used to fill in the matched target component, [document name] and [text block title] are dynamic parameters (such as "5G package change process" chapter of "operation hall business operation manual").
[0102] For example, the summary component includes two sub-components: "Generate [X] summary questions, covering the core goals, implementation framework and key conclusions of [text topic]" and "Ensure that the questions cover the overall logic and core elements of [business board]". The parameter [X] corresponds to the number of questions, and [text topic] is associated with the document title (such as "5G package marketing promotion"). The detailed component includes three sub-components: "Generate [X] detailed questions, focusing on [operation scene] step specifications, data standards and execution points" and "Ask questions related to specific operation parameters for [business segment]". The parameter [operation scene] corresponds to the last title (such as "new user network access identity verification"). The comparative component includes two sub-components: "Generate [X] comparative questions to analyze the differences between [target business] and [reference object] from [comparison dimension]". The parameter [comparison dimension] is preset as "tariff standard", "service range", "handling process" and other common dimensions of telecom business. The trend component includes two sub-components: "Generate [X] trend questions, combined with [industry dynamics] to predict the development direction of [business field]". The parameter [industry dynamics] is associated with keywords such as "5G penetration rate" and "digital transformation". The term explanation component includes two sub-components: "Generate [X] term explanation questions to clarify the definition, application scenario and business meaning of [professional term]". The parameter [professional term] is extracted from high-frequency technical terms in the document (such as "SA independent networking" and "package contract period"). The exception handling component includes two sub-components: "Generate [X] exception questions to cover the abnormal trigger conditions, processing steps and rollback mechanism of [business process]". The parameter [business process] corresponds to scenarios such as "failed charge" and "package change cancellation".
[0103] S804, based on the question distribution strategy, match the target component from the prompt word component library.
[0104] Based on the previous example, for the H1 text block, the question distribution strategy is to generate 36 summary questions, 6 comparative analysis questions, and 18 trend questions. Then match the components and templates of summary questions, comparative analysis questions, and trend questions from the prompt word component library.
[0105] S806, fill the target component to the placeholder of the prompt template to generate a prompt.
[0106] For example, scenario 1: summary question generation: after filling the template placeholder, the generated prompt is: "Based on the content of the 'overall strategy' chapter of the document 'Telecom 5G package marketing service specification', generate 3 summary questions that cover the core goals, implementation framework and key conclusions of 5G package marketing. The questions must comply with the telecom business terminology specification, avoid repetition and cover core information." Scenario 2: detailed question generation: after filling the template placeholder, the generated prompt is: "Based on the content of the 'ID card information verification steps' chapter of the document 'Business hall business operation manual', generate 2 detailed questions that involve specific operation parameters for ID card validity period verification and information input. The questions must comply with the telecom business terminology specification, avoid repetition and cover core information."
[0107] S808, input the prompt into the large language model to extract a question list from each text block.
[0108] In this embodiment, after inputting the prompt generated by S806, such as "Based on the content of the 'overall strategy' chapter of the document 'Telecom 5G package marketing service specification', generate 3 summary questions that cover the core goals, implementation framework and key conclusions of 5G package marketing. The questions must comply with the telecom business terminology specification, avoid repetition and cover core information." into the large language model (such as a telecom domain large language based on industry training), the output question list includes 3 summary questions.
[0109] In some embodiments, the prompt is input into the large language model to extract a candidate question list from each text block, and then the final question list is determined by manually screening the candidate questions. Manual screening can further improve the usage rate of the final generated question and answer corpus and the accuracy of customer consultation matching.
[0110] In this embodiment, the fusion of question distribution strategy and dynamic assembly prompt can improve the fit of questions and document structure, enhance question diversity, avoid question type distribution imbalance, and reduce invalid question generation.
[0111] In some embodiments, Figure 9 A specific question corpus generation system is provided for the embodiments of the present disclosure, which combines Figure 9The question and answer corpus generation system provided by the embodiments of the present disclosure can include a text blocking module 91 based on document hierarchical semantic segmentation and content recursive summary, a question generation module 92 of title weight analysis and dynamic prompt assembly, and a high-quality corpus data generation module 93. The text blocking module 91 based on document hierarchical semantic segmentation and content recursive summary is connected to the question generation module 92 of title weight analysis and dynamic prompt assembly, and the question generation module 92 of title weight analysis and dynamic prompt assembly is connected to the high-quality corpus data generation module 93. The input of the text blocking module 91 based on document hierarchical semantic segmentation and content recursive summary can be a structured document, which is used to obtain a target document including multiple hierarchical titles and text content corresponding to each hierarchical title. The target document is text blocked according to the multiple hierarchical titles and the text content corresponding to each hierarchical title, and a plurality of text blocks are obtained. The output is a text block list. The question generation module 92 of title weight analysis and dynamic prompt assembly receives the text block list output by the text blocking module 91 based on document hierarchical semantic segmentation and content recursive summary, determines a question assignment strategy for each text block based on the hierarchical title level of each text block and the text content of each text block, extracts a question list from each text block based on the question assignment strategy and a prompt word template, thereby obtaining a plurality of high-quality questions, and then inputs the plurality of high-quality questions into the high-quality corpus data generation module 93 to generate high-quality question and answer corpus.
[0112] Specifically, the text blocking module 91 based on document hierarchical semantic segmentation and content recursive summary includes a document hierarchical tree structure construction unit 911, a text block range definition unit 912, and a recursive text block generation unit 913. The question generation module 92 of title weight analysis and dynamic prompt assembly includes a title level analysis unit 921, a question dynamic quota unit 922, a prompt word dynamic assembly unit 923, a large language model interaction unit 924, a candidate question unit 925, and a manual judgment unit 926.
[0113] In the embodiments, by applying the text blocking technology based on document hierarchical semantic segmentation and content recursive summary and the question generation technology of title weight analysis and dynamic prompt assembly, the question and answer corpus can be efficiently and batch generated according to the vertical domain knowledge. The method effectively solves the problems of low efficiency, limited coverage and lack of inspiration in the process of manually collecting corpus.
[0114] Based on the same inventive concept, the embodiments of the present disclosure also provide a question and answer corpus generation device, as described in the following embodiments. Since the principle of solving problems of the device embodiments is similar to that of the above-mentioned method embodiments, the implementation of the device embodiments can be referred to the implementation of the above-mentioned method embodiments, and the repeated parts will not be described here.
[0115] Figure 10This diagram illustrates a question-and-answer corpus generation apparatus according to an embodiment of the present disclosure, such as... Figure 10 As shown, the device includes: an acquisition module 110 for acquiring a target document, the target document including multiple hierarchical headings and text content corresponding to each hierarchical heading; a text segmentation module 120 for segmenting the target document into multiple text blocks according to the multiple hierarchical headings and the text content corresponding to each hierarchical heading; a question allocation strategy determination module 130 for determining a question allocation strategy for each text block based on the hierarchical heading level of each text block and the text content of each text block; a question extraction module 140 for extracting a question list from each text block based on the question allocation strategy and a prompt word template; and a question-and-answer corpus generation module 150 for using a large language model to answer the questions in the question list and generate a question-and-answer corpus.
[0116] In some embodiments, the text segmentation module 120 is specifically used for: constructing a tree structure based on the multiple hierarchical heading levels; generating multiple initial text blocks corresponding to the lowest-level heading to the highest-level heading by tracing back upwards through the hierarchical heading levels based on the tree structure, wherein each of the multiple initial text blocks includes text content corresponding to the hierarchical heading level of the initial text block; and performing dynamic segmentation and summarization on the text content of each of the multiple initial text blocks to obtain multiple text blocks.
[0117] In some embodiments, when the text content of the initial text block does not include a next-level heading, the text segmentation module 120 is specifically configured to: determine the text length of the initial text block based on the text content corresponding to each initial text block; determine whether the text length is greater than the maximum context length supported by the large language model; if so, segment the text content corresponding to the initial text block into multiple text slices, input the multiple text slices into the large language model, and use the output summary result as a text block; wherein, adjacent text slices in the multiple text slices have text content overlap of a preset text length; if not, use the text content corresponding to the initial text block as a text block.
[0118] In some embodiments, when the text content of the initial text block includes a next level title, the text chunking module 120 is specifically configured to: determine the text length of the initial text block according to the text content corresponding to each initial text block; determine whether the text length is greater than the maximum context length supported by the large language model; if yes, according to the proportion of the text length of the text content corresponding to the next level title in the total text length of the initial text block, assign an abstract length proportion, and use the large language model to abstract the text content corresponding to the next level title according to the abstract length proportion, and then combine the abstract results to output the abstract result as a text block; if not, the text content corresponding to the initial text block is taken as a text block.
[0119] In some embodiments, the question distribution strategy determination module 130 is specifically configured to: determine the question type and the weight of the question type of each text block based on the mapping relationship between the hierarchical title level of each text block and the hierarchical question distribution matrix, wherein the hierarchical question distribution matrix includes the question type corresponding to each title level and the weight of the question type; determine the number of questions of each text block according to the text content of each text block and the weight of the question type; and determine the question distribution strategy of each text block according to the question type and the number of questions of each text block.
[0120] In some embodiments, the question distribution strategy determination module 130 is specifically configured to: determine the total number of questions of each text block according to the text length of the text content of each text block and a preset threshold; determine the number of each question type according to the total number of questions of each text block and the weight of the question type; and determine the number of questions of each text block according to the number of each question type.
[0121] In some embodiments, the question extraction module 140 is further configured to: construct a prompt word component library and a prompt word template containing a placeholder; and the question extraction module 140 is specifically configured to: match a target component from the prompt word component library based on the question distribution strategy; fill the target component into the placeholder of the prompt word template to generate a prompt word; and input the prompt word into a large language model to extract a question list from each text block.
[0122] It should be noted that each module in the above device embodiment and the corresponding steps in the method embodiment have the same examples and application scenarios, but are not limited to the content disclosed in the above method embodiments. It should be noted that the above modules as part of the device can be executed in a computer system such as a group of computer executable instructions.
[0123] Those skilled in the art can understand that each aspect of the present disclosure can be embodied in the form of a complete hardware embodiment, a complete software embodiment (including firmware, microcode, etc.), or an embodiment combining software and hardware aspects, which can be collectively referred to as "circuitry", "module" or "system" herein.
[0124] Based on the same inventive concept, the electronic device in the embodiments of the present disclosure also provides an electronic device, which comprises: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the above-mentioned any one of the question and answer corpus generation method via execution of the executable instructions. Since the principle of solving problems of the electronic device embodiment is similar to that of the above-mentioned method embodiment, the implementation of the electronic device embodiment can be referred to the implementation of the above-mentioned method embodiment, and the repeated parts will not be described here.
[0125] The electronic device 1100 according to this embodiment of the present disclosure will be described below with reference to Figure 11 Figure 11 The display electronic device 1100 is only an example and should not impose any limitation on the functions and use range of the embodiments of the present disclosure.
[0126] As shown in Figure 11 The components of the electronic device 1100 can include, but are not limited to, the above-mentioned at least one processing unit 1110, the above-mentioned at least one storage unit 1120, and a bus 1130 connecting different system components, including the storage unit 1120 and the processing unit 1110.
[0127] The storage unit stores program codes which can be executed by the processing unit 1110, so that the processing unit 1110 performs the steps according to various exemplary embodiments of the present disclosure described in the above "Exemplary Method" section of the present specification. For example, the processing unit 1110 can perform the following steps of the above-mentioned method embodiment: obtaining query corpus; inputting the query corpus into the retriever to output the first retrieval result; inputting the first retrieval result into the pre-trained retrieval optimization generation model to output the second retrieval result; wherein the retrieval optimization generation model is trained according to the historical query corpus and the query result corresponding to the historical query corpus, and the query result corresponding to the historical query corpus is obtained by the large language model; inputting the second retrieval result into the large language model to output the query result.
[0128] The storage unit 1120 can include a readable medium in the form of a volatile storage unit, such as a random access memory (RAM) 11201 and / or a cache memory unit 11202, and can further include a read-only memory (ROM) 11203.
[0129] The storage unit 1120 can also include a program / utility 11204 having a set of programs / modules 11205, each of which performs one or more tasks. The programs and modules 11205 can include, but are not limited to, one or more of the following: an operating system, one or more application programs, other program modules, and program data, each of which can include implementations of the network environment, alone or in combination with one another.
[0130] The bus 1130 can represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration bus, a processor or local bus using any of a variety of bus architectures, and so on.
[0131] The electronic device 1100 can also communicate with one or more external devices 1140 such as a keyboard or pointing device, using one or more communication interfaces 1150. Communication interfaces 1150 can include, without limitation, a wireless network interface, a Bluetooth® interface, a USB interface, a modem, a serial port, a game port, and / or a parallel port. The communication interfaces 1150 can be used to enable the electronic device 1100 to communicate with one or more devices using any one or more of various communication protocols, including without limitation, Bluetooth® protocols, WiFi® protocols, and / or other protocols. The electronic device 1100 can also include one or more antennas 1152 for transmitting and / or receiving wireless signals. The antennas 1152 can be used to enable the electronic device 1100 to communicate with one or more devices using any one or more of various wireless communication protocols, including without limitation, Bluetooth® protocols, WiFi® protocols, and / or other protocols. The communication interfaces 1150 and / or antennas 1152 can be used to enable the electronic device 1100 to communicate with one or more devices using any one or more of various wired and / or wireless communication protocols, including without limitation, Bluetooth® protocols, WiFi® protocols, and / or other protocols.
[0132] Those skilled in the art will readily understand that the example embodiments described herein can be implemented by software and / or by software in combination with the necessary hardware. Thus, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash disk, a mobile hard disk, or the like) or a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to perform the methods according to the embodiments of the present disclosure.
[0133] Based on the same inventive concept, the disclosure also provides a computer readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the question-answer corpus generation method of any of the above. Since the computer readable storage medium embodiment solves the problem in the same principle as the above method embodiment, the implementation of the computer readable storage medium embodiment can be referred to the implementation of the above method embodiment, and the repeated parts will not be described here.
[0134] More specific examples of the computer readable storage medium in the present disclosure can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0135] In the present disclosure, the computer readable storage medium can include a data signal carried in the baseband or as a part of a carrier wave, in which readable program codes are borne. Such a propagated data signal can take multiple forms, including but not limited to electro-magnetic signal, optical signal, or any suitable combination of the foregoing. The readable signal medium can also be any readable medium that can send, propagate or transfer program for use by an instruction execution system, apparatus or device, or in conjunction with which the program codes are used.
[0136] Optionally, the program codes contained in the computer readable storage medium can be transmitted by any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0137] In specific implementation, the program codes for executing the operations of the present disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" language or similar programming languages. The program codes can be executed entirely on a user computing device, partially on a user device, as an independent software package, partially on a user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case involving a remote computing device, the remote computing device can be connected to the user computing device through any kind of network, including local area network (LAN) or wide area network (WAN), or can be connected to an external computing device (for example, connected through the Internet by using an Internet service provider).
[0138] Based on the same inventive concept, the embodiments of the present disclosure also provide a computer program product, comprising a computer program product, comprising: a computer program or instructions, which, when executed by a processor, implements the question-answer corpus generation method of any one of the above method embodiments. Since the principles of the computer program product embodiment for solving problems are similar to those of the above method embodiments, the implementation of the computer program product embodiment can be referred to the implementation of the above method embodiments, and the repeated parts will not be described here.
[0139] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, such division is not mandatory. Indeed, according to embodiments of the present disclosure, the features and functionalities of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functionalities of one module or unit described above can be further divided into several modules or units embodied.
[0140] Furthermore, although the various steps of the methods of the present disclosure are described in a particular order in the figures, this is not required or implied as to the order of execution of the steps, nor is it required that all of the steps be executed to achieve the desired result. Additionally or alternatively, certain steps can be omitted, multiple steps can be combined into one step, one step can be broken into multiple steps, etc.
[0141] From the above description of the embodiments, those skilled in the art will readily appreciate that the example embodiments described herein can be implemented by software and / or by hardware. Accordingly, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or a network, and includes a number of instructions for causing a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to perform the methods according to the embodiments of the present disclosure.
[0142] Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the aspects of the present disclosure disclosed herein. It is intended that the present disclosure cover any and all variations of the present disclosure that come within the scope of the claims and their equivalents. It is intended that the specification and examples be considered exemplary only, with the true scope and spirit of the disclosure being indicated by the following claims.
Claims
1. A method for generating question-and-answer corpora, characterized in that, The method includes: Obtain the target document, which includes multiple hierarchical headings and the text content corresponding to each hierarchical heading; The target document is divided into multiple text blocks based on the multiple hierarchical headings and the text content corresponding to each hierarchical heading; Based on the hierarchical heading level of each text block and the text content of each text block, determine the question allocation strategy for each text block; Based on the question allocation strategy and prompt word template, a question list is extracted from each text block; The question-and-answer corpus is generated by answering the questions in the question list using a large language model.
2. The question-and-answer corpus generation method according to claim 1, characterized in that, The step of dividing the target document into text blocks based on the multiple hierarchical headings and the text content corresponding to each hierarchical heading, resulting in multiple text blocks, includes: A tree structure is constructed based on the multiple hierarchical heading levels; Based on the tree structure, multiple initial text blocks are generated by tracing back from the hierarchical heading level to the highest level heading. Each of the multiple initial text blocks includes text content corresponding to the hierarchical heading level of the initial text block. The text content of each initial text block in the plurality of initial text blocks is dynamically segmented and summarized to obtain a plurality of text blocks.
3. The question-and-answer corpus generation method according to claim 2, characterized in that, When the text content of the initial text block does not include the next level heading, the dynamic block summarization of the text content corresponding to each of the multiple initial text blocks yields multiple text blocks, including: The text length of each initial text block is determined based on the text content corresponding to each initial text block; Determine whether the length of the text is greater than the maximum context length supported by the large language model; If so, the text content corresponding to the initial text block is cut into multiple text slices, and the multiple text slices are input into the large language model. The output summary result is used as the text block; wherein, adjacent text slices in the multiple text slices have text content overlap of a preset text length; If not, the text content corresponding to the initial text block shall be used as the text block.
4. The question-and-answer corpus generation method according to claim 2, characterized in that, When the text content of the initial text block includes a next-level heading, the text content corresponding to each of the multiple initial text blocks is dynamically segmented and summarized to obtain multiple text blocks, including: The text length of each initial text block is determined based on the text content corresponding to each initial text block; Determine whether the length of the text is greater than the maximum context length supported by the large language model; If so, based on the proportion of the text length of the text content corresponding to the next level heading in the initial text block to the total text length of the initial text block, allocate the summary length ratio, use the large language model to summarize the text content corresponding to the next level heading according to the summary length ratio, and then merge them. The output summary result is used as the text block. If not, the text content corresponding to the initial text block shall be used as the text block.
5. The question-and-answer corpus generation method according to claim 1, characterized in that, The process of determining the question allocation strategy for each text block based on its hierarchical heading level and text content includes: Based on the mapping relationship between the hierarchical heading level and the hierarchical question distribution matrix of each text block, the question type and weight of each question type are determined, wherein the hierarchical question distribution matrix includes the question type and weight corresponding to each heading level; The number of questions in each text block is determined based on the text content of each text block and the weight of the question type. The question allocation strategy for each text block is determined based on the question type and number of questions in each text block.
6. The question-and-answer corpus generation method according to claim 5, characterized in that, The number of questions for each text block is determined based on the text content of each text block and the weight of the question type, including: The total number of questions for each text block is determined based on the text length of the text content of each text block and a preset threshold. The number of each question type is determined based on the total number of questions in each text block and the weight of each question type; The number of questions for each text block is determined based on the number of questions of each question type.
7. The question-and-answer corpus generation method according to claim 1, characterized in that, The method further includes: Build a prompt word component library and prompt word templates containing placeholders; The step of extracting a list of questions from each text block based on the question allocation strategy and prompt word template includes: Based on the question allocation strategy, target components are matched from the prompt word component library; The target component is filled into the placeholder of the prompt word template to generate the prompt word; The prompt words are input into a large language model to extract a list of questions from each text block.
8. A question-and-answer corpus generation device, characterized in that, The device includes: The acquisition module is used to acquire a target document, which includes multiple hierarchical headings and text content corresponding to each hierarchical heading; The text segmentation module is used to segment the target document into multiple text blocks based on the multiple hierarchical headings and the text content corresponding to each hierarchical heading. The question allocation strategy determination module is used to determine the question allocation strategy for each text block based on the hierarchical heading level of each text block and the text content of each text block; The question extraction module is used to extract a list of questions from each text block based on the question allocation strategy and the prompt word template; The question-and-answer corpus generation module is used to answer questions in the question list using a large language model and generate question-and-answer corpus.
9. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the question-answering corpus generation method according to any one of claims 1-7 by executing the executable instructions.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the question-and-answer corpus generation method according to any one of claims 1-7.
11. A computer program product, comprising: A computer program or instruction, characterized in that, when executed by a processor, the computer program or instruction implements the question-and-answer corpus generation method according to any one of claims 1-7.