Question and answer pair automatic generation method and device based on anchor point perception and electronic equipment
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING ACAD OF ARTIFICIAL INTELLLIGENCE
- Filing Date
- 2026-04-17
- Publication Date
- 2026-08-07
AI Technical Summary
[0006]本发明提供一种基于锚点感知的问答对自动生成方法、装置及电子设备,用以解决现有技术中自动生成的问答对存在指代依赖、语义不完整、质量不可控,导致难以直接用于高质量大模型训练的问题,自动合成高质量的问答训练数据,确保输出的问答训练数据可以直接用于高精度的模型训练
[0018] This invention provides an anchor-aware question-answer pair automatic generation method. It semantically segments the input text document to obtain at least one text block, and uses key objects within each text block as anchors to construct questions. During question construction, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited. The question is then used as the query condition, and the answer is generated by combining the corresponding text block to form a question-answer pair. The quality of the question-answer pairs is evaluated, and pairs containing referential expressions, having external dependencies, or having a comprehensive quality score below a preset threshold are discarded. Finally, the quality-evaluated question-answer pairs are output as training data. This method can automatically generate high-quality question-answer pairs from the original text document that are semantically complete, unambiguous in referential meaning, and independent of external context, significantly improving the accuracy of training data and the model fine-tuning effect. Simultaneously, through explicit anchor embedding and a multi-dimensional quality evaluation mechanism, it effectively avoids common problems in traditional automatic generation methods such as information distortion, phantom answers, and context dependencies.
Smart Images

Figure CN122527262A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to a method, apparatus and electronic device for automatically generating question-answer pairs based on anchor point awareness. Background Technology
[0002] In training large language models, high-quality question-answer pairs are key data resources for improving the model's understanding and reasoning abilities.
[0003] Existing automatic question-answering generation methods typically generate questions and answers directly from document fragments, but they generally have significant drawbacks: the generated questions often rely on contextual references (such as "this method" or "the above content"), resulting in semantically incomplete question-answer pairs when separated from the original text; at the same time, they lack effective quality control mechanisms, making it difficult to guarantee the fidelity, independence, and overall reliability of the answers.
[0004] Furthermore, due to the coarseness of the generation strategy, the question types are often limited to simple fact extraction, making it difficult to cover higher-order semantic dimensions such as mechanism explanation and design rationale. These problems result in automatically generated question-and-answer data being noisy and unusable, requiring extensive manual cleaning before it can be used for model training, which severely restricts the large-scale construction of high-quality training data.
[0005] Therefore, there is an urgent need for an automated method that can generate question-answer pairs that are free from referential dependencies, semantically consistent, and of controllable quality. Summary of the Invention
[0006] This invention provides an anchor-aware question-and-answer pair automatic generation method, apparatus, and electronic device to solve the problems in existing technologies where automatically generated question-and-answer pairs suffer from referential dependence, incomplete semantics, and uncontrollable quality, making them difficult to use directly for high-quality large-scale model training. It automatically synthesizes high-quality question-and-answer training data, ensuring that the output question-and-answer training data can be directly used for high-precision model training.
[0007] On one hand, this invention provides an anchor-aware question-answer pair automatic generation method, comprising: semantically segmenting an input text document to obtain at least one text block; constructing a question using key objects in each text block as anchors; wherein, when constructing the question, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited; generating an answer by combining the question with the corresponding text block, using the question as a query condition, to form a question-answer pair; performing a quality assessment on the question-answer pair, and removing question-answer pairs that contain referential expressions, have external dependencies, or have a comprehensive quality score below a preset threshold; and outputting question-answer pairs that pass the quality assessment as training data.
[0008] Furthermore, the step of constructing a question by using key objects in each text block as anchor points includes: extracting at least one key object from the text block as an anchor point; for each anchor point, performing an applicability judgment based on a preset question type; and for an applicable question type, generating a corresponding question based on the combination of the anchor point and the question type.
[0009] Furthermore, the preset question types include at least two of the following: fact extraction, mechanism explanation, design reasons, conditional constraints, limitation trade-offs, and comparative relationships.
[0010] Furthermore, for each anchor point, the applicability judgment based on the preset question type includes: for each question type other than the fact extraction type, detecting whether the text block contains keywords related to the question type; if no keywords are detected, calling the large language model to determine whether the text block is suitable for generating questions of the question type.
[0011] Furthermore, the step of generating an answer based on the question as a query condition and combining it with the text block corresponding to the question to form a question-answer pair includes: generating candidate answers based on multiple different large language models, respectively, according to the question and the text block; using a review model to score each candidate answer from the dimensions of fidelity, accuracy, completeness, professionalism, independence, and fluency; and selecting the optimal candidate answer as the final answer based on the scoring results to form a question-answer pair.
[0012] Furthermore, the quality assessment of the question-answer pair includes: detecting whether the question-answer pair contains referential expressions; using a large language model to determine whether the question-answer pair has external dependencies; the external dependencies include information referenced by the question-answer pair that is not explicitly contained in the corresponding text block or the question-answer pair requiring content outside the text block to be understood; calling the large language model to score the question-answer pair from the dimensions of answerability, fidelity, question quality, and answer quality, and calculating a weighted comprehensive quality score.
[0013] Furthermore, the step of semantically segmenting the input text document to obtain at least one text block includes: performing sliding window segmentation on the text document based on a large language model, and preserving semantically overlapping areas between adjacent windows to generate semantically coherent text blocks.
[0014] Secondly, the present invention also provides an anchor-aware question-answer pair automatic generation device, comprising: a semantic segmentation module, which performs semantic segmentation on the input text document to obtain at least one text block; a question construction module, which constructs a question by using key objects in each text block as anchors; wherein, when constructing a question, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited; an answer generation module, which generates an answer by combining the question as a query condition with the text block corresponding to the question, thus forming a question-answer pair; a quality assessment module, which performs quality assessment on the question-answer pairs, and removes question-answer pairs that contain referential expressions, have external dependencies, or have a comprehensive quality score lower than a preset threshold; and a question-answer pair output module, which outputs question-answer pairs that pass the quality assessment as training data.
[0015] Thirdly, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the anchor-aware question-answer pair automatic generation method as described above.
[0016] Fourthly, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the anchor-aware question-answer pair automatic generation method as described above.
[0017] Fifthly, the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the anchor-aware question-answer pair automatic generation method as described above.
[0018] This invention provides an anchor-aware question-answer pair automatic generation method. It semantically segments the input text document to obtain at least one text block, and uses key objects within each text block as anchors to construct questions. During question construction, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited. The question is then used as the query condition, and the answer is generated by combining the corresponding text block to form a question-answer pair. The quality of the question-answer pairs is evaluated, and pairs containing referential expressions, having external dependencies, or having a comprehensive quality score below a preset threshold are discarded. Finally, the quality-evaluated question-answer pairs are output as training data. This method can automatically generate high-quality question-answer pairs from the original text document that are semantically complete, unambiguous in referential meaning, and independent of external context, significantly improving the accuracy of training data and the model fine-tuning effect. Simultaneously, through explicit anchor embedding and a multi-dimensional quality evaluation mechanism, it effectively avoids common problems in traditional automatic generation methods such as information distortion, phantom answers, and context dependencies. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating the automatic generation method for question-answer pairs based on anchor point awareness provided in an embodiment of the present invention.
[0021] Figure 2 This is a schematic diagram of anchor-aware question generation in the anchor-aware question-answer pair automatic generation method provided in the embodiment of the present invention.
[0022] Figure 3 This is a schematic diagram of the answer generation and voting mechanism of the question-answer pair automatic generation method based on anchor point awareness provided in the embodiments of the present invention.
[0023] Figure 4 This is a schematic diagram of the overall process of the question-answer pair automatic generation method based on anchor point awareness provided in the embodiments of the present invention.
[0024] Figure 5 This is a schematic diagram of the three-layer quality filtering mechanism of the anchor-aware question-answer pair automatic generation method provided in the embodiments of the present invention.
[0025] Figure 6 This is a schematic diagram of the structure of the question-answer pair automatic generation device based on anchor point awareness provided in an embodiment of the present invention.
[0026] Figure 7 This is a schematic diagram of the physical structure of the electronic device provided in the embodiment of the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0028] Figure 1 The diagram shows a flowchart of the automatic question-answer pair generation method based on anchor point awareness provided in an embodiment of the present invention.
[0029] like Figure 1As shown, the method includes: S110, semantically segmenting the input text document to obtain at least one text block; S120, constructing a question using key objects in each text block as anchors; wherein, when constructing the question, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited; S130, generating an answer by combining the question with the text block corresponding to the question, forming a question-answer pair; S140, performing a quality assessment on the question-answer pair, and removing question-answer pairs that contain referential expressions, have external dependencies, or have a comprehensive quality score below a preset threshold; S150, outputting the question-answer pairs that pass the quality assessment as training data.
[0030] The following will provide a detailed description of steps S110-S150 and related steps.
[0031] S110, Semantically segment the input text document to obtain at least one text block.
[0032] In step S110, the system first receives a text document uploaded by the user, such as a PDF technical report on distributed systems. To avoid semantic breaks caused by mechanically segmenting by a fixed number of words, the system adopts a segmentation strategy based on semantic coherence: it traverses the document in a sliding window manner, taking a continuous text segment as a candidate block each time, and using a large language model to determine whether the end of the current window constitutes a semantic boundary, such as a topic transition, paragraph end, or logical unit completion. If it is determined to be a reasonable segmentation point, the content of that window is determined as a text block; some overlapping content is retained between adjacent text blocks, such as the last two sentences, to maintain contextual coherence. Finally, several semantically complete and topic-focused text blocks are output for subsequent processing.
[0033] S120, construct a question by using key objects in each text block as anchors; wherein, when constructing a question, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited.
[0034] After semantically segmenting the input text document in step S110 to obtain at least one text block, the system further identifies key technically significant objects within each text block. For example, in a paragraph describing the "Raft consensus algorithm," terms such as "Raft," "leader election," and "log replication" are identified as candidate anchor points. Subsequently, the system matches each anchor point with a preset question template, such as "How does {anchor point} work?" or "What is the design purpose of {anchor point}?".
[0035] When generating questions, the system mandates that the full, original name of the anchor (e.g., "Raft consensus algorithm" rather than "it" or "the algorithm") be entered into the template, and uses rule checks to ensure that the question text does not contain any pronouns or vague references. For example, if the original text mentions "Raft maintains its leader through a heartbeat mechanism," the system will not generate "How does it maintain its leader?", but rather "How does the Raft consensus algorithm maintain its leader through a heartbeat mechanism?". This process ensures that each question is semantically closed and can be understood without needing to go back into the context.
[0036] S130, using the question as the query condition, and combining the text block corresponding to the question to generate an answer, forming a question-answer pair.
[0037] After constructing questions by using key objects in each text block as anchors in step S120, the system further binds each question generated in S120 to its source text block as the unique context for answer generation.
[0038] Subsequently, one or more large language models, such as LLaMA or ChatGLM with fine-tuned instructions, are invoked. Guided by the prompt "Answer the question based on the following text", the question and the corresponding text block are input into the model to generate candidate answers.
[0039] For example, for the question "How does the Raft consensus algorithm maintain its leader through a heartbeat mechanism?", the model can only generate an answer based on the text block corresponding to the question (i.e., the section containing the description of the Raft heartbeat mechanism), and must not reference other parts of the document or external knowledge. After the generated answer is validated for format, it is paired with the question to form a preliminary question-answer pair.
[0040] S140, perform quality assessment on the question-answer pairs, and remove question-answer pairs that contain referential expressions, have external dependencies, or have a comprehensive quality score below a preset threshold.
[0041] In step S130, the question is used as the query condition, and the answer is generated by combining the text block corresponding to the question to form a question-answer pair. Then, a three-layer quality filter is performed on each initially generated question-answer pair.
[0042] The first layer detects whether the question or answer contains referential expressions such as "it", "the method", or "the above components" through keyword matching and syntactic analysis. Once found, it is marked as unqualified.
[0043] The second layer uses a large language model to determine whether the question-answer pair has external dependencies, that is, to determine whether the corresponding text block alone is sufficient to support the question and answer content. For example, if the question asks "Why choose Raft instead of Paxos?", but the corresponding text block does not mention Paxos, then it is determined that there is an external dependency and is removed.
[0044] The third layer calls another large language model to score the questions from four dimensions: answerability (whether the question is clear), fidelity (whether the answer is faithful to the text block), question quality (whether it is clear and unambiguous), and answer quality (whether it is complete and accurate). The scores are then weighted to obtain a comprehensive quality score. If the score is lower than a preset threshold (e.g., 0.75), the question is also rejected.
[0045] The preset threshold, set by the system developer or data engineer before deployment, is a configurable hyperparameter used to balance the quantity and quality of generated question-answer pairs. If high-precision training data is desired, such as for high-risk fields like healthcare or finance, the preset threshold can be set to a higher value (e.g., 0.85) to strictly filter low-quality samples. If the focus is on data breadth, such as for general domain pre-training, the threshold can be appropriately lowered (e.g., 0.65) to retain more diverse question-answer pairs.
[0046] Finally, only question-answer pairs that pass all three layers of quality filtering proceed to the next stage, namely step S150.
[0047] S150 outputs question-answer pairs that pass the quality assessment as training data.
[0048] The question-answer pairs ultimately retained from step S140 are uniformly organized into a structured format, such as a JSON object per line containing "question" and "answer" fields, and written to a specified storage path or directly pushed to the model training pipeline.
[0049] These question-answer pairs that pass the quality assessment are characterized by explicit anchor embedding, no referentiality, no external dependencies, and overall quality compliance. They can be directly used for supervised fine-tuning of large language models, significantly improving the accuracy and robustness of the model in question-answering tasks in specific domains.
[0050] In this embodiment, the input text document is semantically segmented to obtain at least one text block, and key objects in each text block are used as anchors to construct questions. When constructing questions, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited. Then, using the question as the query condition, answers are generated by combining the text block corresponding to the question, forming question-answer pairs. The question-answer pairs are then evaluated for quality, and pairs containing referential expressions, having external dependencies, or having a comprehensive quality score below a preset threshold are removed. Finally, the question-answer pairs that pass the quality evaluation are output as training data. This method can automatically generate high-quality question-answer pairs from the original text document that are semantically complete, unambiguous in referential meaning, and independent of external context, significantly improving the accuracy of training data and the model fine-tuning effect. Simultaneously, through explicit anchor embedding and a multi-dimensional quality evaluation mechanism, it effectively avoids information distortion, phantom answers, and context-dependent problems common in traditional automatic generation methods.
[0051] Based on the above embodiments, the following will further describe in detail the process of semantic segmentation of the input text document in step S110.
[0052] Semantic segmentation of the input text document yields at least one text block, including: performing sliding window segmentation on the text document based on a large language model, preserving semantically overlapping regions between adjacent windows, and generating semantically coherent text blocks.
[0053] As is easily understood, the system first receives user-provided input text (text documents) and supports both plain text formats (such as .txt files) and structured formats (such as HTML, Markdown, or tagged text converted from PDF). For structured formats, the system preserves the original logical structure information such as paragraphs, headings, or lists during reading to more accurately identify semantic boundaries in subsequent processing; for plain text, it parses directly as a character stream. Regardless of the format, the system uniformly converts it into an internally standardized text representation as the input source for subsequent processing.
[0054] Subsequently, the system invokes a pre-trained quality classification model to perform an overall quality assessment of the entire text document. This quality classification model is a binary classification or regression model derived from fine-tuning of a large language model. It comprehensively judges dimensions such as content completeness, language standardization, information density, and technical relevance of the text document, and outputs a normalized quality score.
[0055] If the quality score is lower than the preset file-level threshold, or the total length of the text document is less than the minimum valid length (e.g., less than 50 valid words), the text document is determined to be too short or of too low quality, and the system will directly discard the text document and not proceed to the subsequent segmentation process. This step effectively avoids interference from low-value noise data on the question-and-answer pair generation system, improving overall processing efficiency and output quality.
[0056] Finally, for high-quality text documents that have passed the file-level filtering, the system performs sliding window segmentation on the text documents based on a large language model, and retains semantically overlapping areas between adjacent windows to generate semantically coherent text blocks.
[0057] Specifically, a sliding window mechanism is used to traverse the entire text document. The window size and sliding step can be dynamically adjusted according to the document type. At each sliding position, a large language model is invoked to analyze the semantic integrity of the text within the current window, determining whether it is at a natural semantic boundary, such as a topic transition point, paragraph end, or the end of a logical reasoning unit. When the model confirms that it can be segmented, the text from the previous segmentation point to the current judgment position is extracted as a candidate text block.
[0058] Crucially, to ensure contextual coherence, when generating adjacent text blocks, the system mandates that the beginning of the subsequent text block includes the end of the preceding text block, forming a semantically overlapping region. This overlapping region is not simply a fixed repetition of characters; rather, its length and boundaries are dynamically determined by the large language model based on the semantic relevance of the context, ensuring that each text block still contains sufficient preceding contextual information when used independently, thereby maintaining semantic integrity.
[0059] The final output text blocks all possess the characteristics of local topic focus, logical consistency, and semantic coherence, providing a reliable foundation for subsequent anchor point recognition and question-answer pair construction.
[0060] Based on the above embodiments, the following will further describe in detail the process of constructing a problem by using key objects in each text block as anchor points in step S120.
[0061] Constructing questions by using key objects in each text block as anchors includes: extracting at least one key object from the text block as an anchor; for each anchor, determining its applicability based on a preset question type; and for applicable question types, generating corresponding questions based on the combination of anchors and question types.
[0062] Figure 2 The diagram illustrates the anchor-aware question generation method of the automatic question-answer pair generation method based on anchor-awareness provided in an embodiment of the present invention.
[0063] like Figure 2 As shown, firstly, after receiving multiple text blocks obtained through semantic segmentation, the system independently performs text block filtering for each text block. This filtering operation is based on a preset quality assessment model, which comprehensively scores the text block's linguistic fluency, information density, technical relevance, and semantic integrity. If a text block's comprehensive score is lower than a set block-level quality threshold, for example, due to logical breaks caused by truncation, empty content, or excessive noise, the text block is directly rejected and will not participate in the subsequent question generation process, thus ensuring that only high-quality text fragments are used to construct reliable question-answer pairs.
[0064] Subsequently, for the filtered text blocks, at least one key object is extracted as an anchor point. Here, a key object refers to an entity or concept in the text block that has a clear designation, is independently identifiable, and carries core information, including but not limited to technical terms, component names, algorithm names, parameter indicators, method flows, or system modules. When extracting key objects, they are selected based on their importance and semantic redundancy, ultimately retaining no more than five of the most representative key objects as anchor points to balance the breadth of problem coverage with generation accuracy. The extraction process can combine named entity recognition and domain dictionary matching, and a large language model can be used to assist in confirming their importance and representativeness in the current context.
[0065] Next, an applicability judgment for the question type is performed for each anchor point. The preset question types include at least two of the following: fact extraction, mechanism explanation, design reasons, conditional constraints, limitation trade-offs, and comparative relationships, as shown in Table 1 below.
[0066] Among them, fact extraction, as a basic and general type, requires no additional judgment and is always applicable to all anchor points; while for the other problem types, namely mechanism explanation, design reasons, condition constraints, limitation trade-offs, and comparison relationships, the system adopts a two-level checking mechanism to determine applicability.
[0067] The first level is keyword matching: The system maintains a keyword library associated with each question type. For example, "because," "purpose," and "aimed at" correspond to design reasons; "premise," "only if," and "limitation" correspond to conditional constraints; "however," "cost," and "insufficiency" correspond to limitations and trade-offs; and "compared to," "different from," and "better than" correspond to comparative relationships, etc. The system checks whether the current text block contains keywords related to a specific question type. If detected, it determines that the question type applies to the current text block.
[0068] The second level is model judgment: If no relevant keywords are detected in the first level, the large language model is invoked to perform semantic understanding of the text block content, determining whether it implicitly contains logical structures or information elements that support the question type. For example, even if the text does not contain "because," but describes the performance improvement brought about by a design choice, the large language model can still infer that it applies to the "design reason" type. This second-level mechanism can effectively compensate for the coverage blind spots of keyword matching and improve the robustness and accuracy of type judgment.
[0069] Finally, after determining the set of question types applicable to the current anchor point, the system generates corresponding questions based on the combination of anchor points and question types. For the generated questions, a dual verification process is required: rule checking (including common word detection, length range checking, and anchor point occurrence checking) and large language model validation (including independent comprehensibility, lack of pronoun reference, and clarity of expression). Rule checking serves as a preliminary, rapid filtering step; if any rule fails (e.g., the question contains pronouns, the anchor point is not explicitly present, or the length exceeds the limit), the question is directly filtered out. Only after the rule check passes does the large language model validation stage begin, where the model determines whether the question possesses semantic self-sufficiency and answer-oriented nature. Failure in any validation step results in the question being removed from the subsequent list.
[0070] In other words, the question generation process strictly follows the following core constraints: (1) The full name of the anchor object must be clearly stated in the question and must not be abbreviated or omitted; (2) Any referential expressions such as “this”, “it”, “the method”, “the above scheme”, etc. are prohibited to avoid context dependence; (3) The generated questions must be self-contained, that is, they can still be understood independently and answered directly by the text block content even when separated from the original context; (4) The question content must focus on the angle defined by the selected question type. For example, if “mechanism explanation” is selected, the question should revolve around “how it works” and “what is the process”, rather than asking about its performance values or design motivation.
[0071] For example, if the anchor is "Transformer architecture", the text block describes it as "dynamically weighting each position of the input sequence through a self-attention mechanism", and the applicable types include "mechanism explanation" and "fact extraction", then the generated questions are respectively: "How does the Transformer architecture work?" (mechanism explanation) and "What are the core components of the Transformer architecture?" (fact extraction). Both explicitly contain the complete anchor name, without any reference, and the question angle strictly corresponds to the type definition.
[0072] The questions that pass dual verification form a structured question list, each containing the following fields: [Anchor Name], [Question Text], [Question Type], and [Text Block ID]. This structured question list serves as deterministic input, triggering the subsequent answer generation stage and ensuring end-to-end process traceability and reproducibility.
[0073] This embodiment effectively ensures the semantic clarity, context independence, and type accuracy of the constructed questions through text block filtering, anchor-aware question type applicability judgment, and a multi-type question generation mechanism under strict constraints. It significantly improves the quality and diversity of automatically generated question-answer pairs, avoids common problems such as ambiguous references, missing information, or type mismatch, and provides highly reliable supervision data for fine-tuning of downstream large models.
[0074] Based on the above embodiments, the following will further describe in detail the process of step S130, which uses a question as a query condition and combines it with the text block corresponding to the question to generate an answer and form a question-answer pair.
[0075] Using a question as the query condition, and combining it with the corresponding text block, an answer is generated to form a question-answer pair. This includes: generating candidate answers based on multiple different large language models, respectively, according to the question and the text block; using a review model to score each candidate answer from the dimensions of fidelity, accuracy, completeness, professionalism, independence, and fluency; and selecting the best candidate answer as the final answer based on the scoring results to form a question-answer pair.
[0076] Figure 3 The diagram illustrates the answer generation and voting mechanism of the anchor-aware question-answer pair automatic generation method provided in this embodiment of the invention.
[0077] like Figure 3 As shown, the system receives a combination of "verified question + text block" from the output of the preceding stage. Each question is associated with its original source text block (i.e., a semantically coherent text fragment containing the context on which the question depends). Anchor point explicitness, type adaptability judgment, and double verification have been completed to ensure that the question itself has self-containment and type focus.
[0078] Next, the system selects the generation mode. Based on the trade-off between generation efficiency and quality required in actual application scenarios, the system supports two mutually exclusive answer generation modes: single-model mode and voting mode.
[0079] The single-model mode refers to calling only a single pre-trained large language model to directly generate a candidate answer based on the input question and corresponding text block. Because this mode only performs inference once, it has the advantages of fast response speed and low computational resource consumption, and is suitable for scenarios that require large-scale batch generation of question-answer pairs, such as the initial knowledge base construction or pre-training data expansion stage.
[0080] The voting mode refers to the parallel invocation of multiple large language models with different structures and training data distributions. For example, models A, B, and C, each based on different architectures, fine-tuning goals, or domain specializations, independently generate candidate answers based on the same question and the same text block (i.e., "Step 1:3 model parallel generation"), thereby obtaining a multi-perspective and diverse set of candidate answers. Although this mode has a higher computational cost, it reduces the bias of a single model through model diversity, laying the foundation for subsequent high-quality selection. It is suitable for critical task scenarios with stringent requirements for answer accuracy and professionalism.
[0081] In the voting mode, the generated multiple candidate answers will enter Step 2: LLM voting and review stage. This stage is performed by a dedicated review model that conducts multidimensional evaluation. The review model here is a large language model that has been supervised and fine-tuned. Its task is to perform structured scoring on each candidate answer from six preset dimensions: fidelity, accuracy, completeness, professionalism, independence, and fluency.
[0082] Among these, fidelity refers to whether the answer is strictly based on the provided text, without introducing external speculation or deviating from the original facts. Accuracy refers to whether the answer precisely addresses the core requirements of the question, without irrelevant answers or misplaced key information. Completeness refers to whether the answer covers all necessary information points implied in the question, without any key omissions. Professionalism refers to whether the answer conforms to domain norms, is logically rigorous, uses accurate terminology, and reflects technical depth. Independence refers to whether the answer can be understood independently of the original text, without relying on pronouns (such as "it," "the above") or contextual hints. Fluency refers to whether the language is natural and fluent, with reasonable sentence structure, facilitating human reading and comprehension.
[0083] The review model outputs qualitative or quantitative scores (such as a five-level system) for each dimension, and combines them to form a total score. Based on this, all candidate answers are ranked, and the candidate answer with the highest score is selected as the representative of the "winning answer group".
[0084] Next, in Step 3: the answer synthesis stage, if there is only one winning answer (the typical case), it is directly used as the final answer; if there are multiple high-scoring candidate answers with complementary differences, the system can activate the synthesis mechanism, whereby the synthesis model (also known as the large language model) merges high-quality segments from multiple candidate answers to generate a more comprehensive and concise final answer while maintaining fidelity and independence. This synthesis process is still constrained by the aforementioned six-dimensional criteria to ensure that the output result is not inferior to any of the input candidate answers.
[0085] Finally, the questions are paired with the generated final answers to form structured question-answer pairs, and meta-information such as the text block ID, question type, and generation pattern identifier is added to form a "final question-answer pair record". This record is then transferred to the downstream question-answer pair evaluation stage for manual sampling, automatic evaluation, or model fine-tuning training.
[0086] This embodiment supports a dual-mode answer generation mechanism that combines single-model and voting modes. It also introduces a review model based on six dimensions—fidelity, accuracy, completeness, professionalism, independence, and fluency—to systematically evaluate and select the best answer from multiple candidates. This significantly improves the quality, reliability, and domain adaptability of the generated answers. In particular, in the voting mode, the diversity of multiple large language models and the review synthesis mechanism effectively suppress the illusions, biases, or information omissions inherent in single models. This results in the construction of high-precision, self-contained, and professionally reliable question-answer pairs, providing solid support for the construction of high-quality training data and the application of knowledge services.
[0087] Based on the above embodiments, the process of performing quality assessment on the question-answer pairs in step S140 will be described in detail below.
[0088] The quality assessment of question-answer pairs includes: detecting whether the question-answer pairs contain referential expressions; using a large language model to determine whether the question-answer pairs have external dependencies; external dependencies include information referenced by the question-answer pairs that is not explicitly contained in the corresponding text block or the question-answer pairs needing to rely on content outside the text block to be understood; calling the large language model to score the question-answer pairs from the dimensions of answerability, fidelity, question quality, and answer quality, and calculating a weighted comprehensive quality score.
[0089] The process is straightforward: first, rule checks are performed. Based on a pre-defined list of prohibited words (containing typical referential expressions such as "this article," "this paragraph," "the above," and "as described below"), the question and answer in the question-answer pair are scanned. If any part contains such words, it is considered a referential expression and is discarded. Simultaneously, the system imposes reasonable upper and lower limits on the character length or word count of the question and answer (e.g., questions must be at least 5 characters and no more than 100 characters, and answers must be at least 10 characters and no more than 300 characters) to exclude abnormal samples that are too short (leading to insufficient information) or too long (leading to redundancy and inefficiency). This stage involves rapid, deterministic rule filtering, without relying on model inference.
[0090] Then, a referentiality check is performed. For question-answer pairs that pass the rule check, the system calls a dedicated large language model to determine whether they are independently comprehensible. Independent comprehensibility here means that the question-answer pair can still be accurately interpreted by ordinary readers without having to go back to the original text or rely on implicit background. The large language model focuses on detecting three types of problems: (1) dangling referentiality, such as the answer containing "it improved efficiency" but not specifying what "it" refers to; (2) external document references, such as mentioning "as Figure 1 (2) The figure or chapter is not in the current text block; (3) The subject or key entity is missing, such as the question is “How is the effect?”, which lacks a clear subject. If the large language model determines that the question-answer pair has any form of referential expression or external dependency, the question-answer pair will be immediately filtered and will not be included in the subsequent evaluation.
[0091] Next, a quality assessment is conducted. Question-answer pairs that pass the first two steps will enter the in-depth quality scoring stage. The system calls another specially fine-tuned large language model to perform a structured score on the question-answer pairs from four dimensions: answerability, fidelity, question quality, and answer quality.
[0092] Answerability refers to whether the question itself is clear, specific, and has a clear answer target, and whether there is sufficient information in the corresponding text block to support its answer. Faithfulness refers to whether the answer content is strictly based on the information explicitly contained in the corresponding text block, without introducing facts, inferences, or subjective speculations outside the text block. Question quality refers to whether the question's language is standard, its logic rigorous, and whether it conforms to the structural requirements of its question type (e.g., true / false, cause / effect, definition, etc.). Answer quality refers to whether the answer accurately addresses the question, is complete in information, professionally expressed, and fluently written.
[0093] Each dimension outputs an independent score according to a preset standard (such as a five-point scale), ensuring fine-grained evaluation and interpretability.
[0094] Finally, the scores of the four dimensions mentioned above are weighted according to preset weights (e.g., 20% for answerability, 30% for fidelity, 25% for question quality, and 25% for answer quality; specific weight values can be adjusted according to the application scenario) to obtain a comprehensive quality score. Based on this comprehensive quality score, question-answer pairs are divided into three levels: high quality (e.g., total score ≥ 4.0), medium quality (e.g., 3.0 ≤ total score < 4.0), and low quality (e.g., total score < 3.0). Among them, low-quality question-answer pairs are automatically discarded by the system, and only high-quality and medium-quality question-answer pairs are retained for subsequent applications, such as model training, knowledge base construction, or manual review.
[0095] This embodiment employs a four-stage progressive evaluation mechanism that combines rule checking with a large language model. This mechanism effectively eliminates question-answer pairs containing referential expressions or external dependencies. It also performs a weighted comprehensive score based on four dimensions: answerability, fidelity, question quality, and answer quality. This significantly improves the self-containment, semantic accuracy, and overall reliability of question-answer pairs, and constructs a high-quality question-answer dataset that can be directly used for training or deployment.
[0096] In some other embodiments, Figure 4 The diagram illustrates the overall process of the anchor-aware question-answer pair automatic generation method provided in this embodiment of the invention.
[0097] like Figure 4 As shown, the process begins with the input file (.txt / .json format), which is parsed and divided into two paths: plain text and structured text. Both are then fed into a file-level quality filtering stage. This stage performs quality scoring and length checks, eliminating low-quality or excessively long / short original text documents. Those that pass the quality check proceed to the semantic chunking step, where a large language model segments the long text into semantically coherent and information-complete chunks.
[0098] Next, chunk quality filtering is performed, also based on quality scores and length constraints, to select high-quality text chunks suitable for question generation. Those that pass this stage proceed to the question generation and verification sub-process (marked by the dashed box): First, key objects (such as entities, events, conclusions, etc.) in the text are extracted and identified through anchor points, serving as semantic anchors for question generation; then, type selection is performed, matching preset question types (such as mechanism explanation, design reason, comparative relationship, etc.); next, the anchor-by-anchor generation module combines anchor points and type to generate initial questions; finally, a rule + LLM dual verification process is performed—first, rules verify grammatical and format compliance, then a large language model determines whether the question is clear, answerable, and unambiguous, ensuring that the generated questions are self-contained and type-appropriate.
[0099] After the question generation verification is passed, the answer generation stage begins, which is divided into two parallel paths: the left side is the single model mode, which calls a single pre-trained large language model to directly generate the answer based on the question and the corresponding text block; the right side is the voting mode, which calls three different large language models in parallel to generate candidate answers, and then selects the best answer through a voting mechanism (including LLM review and answer synthesis).
[0100] The generated answer, together with the original question, forms a question-answer pair, which is then sent to the question-answer pair quality assessment module. The module performs a four-step progressive assessment as described in the previous embodiment: rule checking (banned words and length filtering), referentiality checking (LLM-based independent comprehensibility assessment), and multi-dimensional quality scoring (answerability, fidelity, question quality, and answer quality). A weighted comprehensive quality score is then obtained. Entries that do not meet the threshold are discarded, while qualified entries are retained and output as a standard JSONL format question-answer data file for use in downstream model training, evaluation, or knowledge services.
[0101] Furthermore, Figure 5 The diagram illustrates a three-layer quality filtering mechanism for the anchor-aware question-answer pair automatic generation method provided in an embodiment of the present invention.
[0102] like Figure 5As shown, at the top layer (Layer 1: file / record level filtering), "all input data" is received, that is, the original document or data record, such as a single record in a .txt / .json file. This layer performs coarse-grained filtering, mainly based on three criteria: (1) quality score: the entire file or record is initially scored based on preset indicators; (2) length check: abnormal records that are too short (insufficient information) or too long (redundant and inefficient) are removed; (3) classification model evaluation: the classification model is used to determine whether the type of the record is suitable for the subsequent question-and-answer pair generation task, such as excluding non-narrative content such as pure code, tables, and advertisements. For structured input, the strategy of "structured input: using pre-computed multi-dimensional quality score" is also introduced, that is, reusing existing metadata or pre-processed scores to accelerate the judgment. Any file that does not meet any condition is marked as a "low-quality file" and is discarded by the "filter" exit guided by the red arrow; those that pass the filter enter the next layer.
[0103] In the middle layer (Layer 2: text block-level filtering), the input is a high-quality file filtered by Layer 1, which is semantically segmented to generate several text blocks (Chunks). This layer focuses on quality control at the text block level, including: (1) text block quality scoring, scoring each Chunk independently; (2) text block length checking, ensuring that the Chunk length is appropriate, taking into account both information integrity and processability; (3) a classification model scoring each text block independently, further identifying whether the block contains effective knowledge units (such as arguments, facts, definitions), and excluding transitional sentences and repetitive paragraphs without substantial content. Chunks that do not meet the requirements are judged as "low-quality blocks", exported and filtered by orange arrows; qualified blocks continue to flow downwards.
[0104] At the lowest level (Layer 3: Question-Answer Pair Level Evaluation), the input consists of candidate question-answer pairs generated from qualified text blocks, and the most refined and rigorous final evaluation is performed. This includes Steps 1-4.
[0105] Step 1: Rule Check – Disable word screening and length limits to exclude question-answer pairs containing referential expressions (such as "this article" or "the above"). Step 2: Referential Check – Utilize the large language model to determine if there are external dependencies, i.e., information not explicitly included in the referenced text or requiring external content for comprehension. Step 3: LLM Quality Assessment – The large language model scores the questions based on four dimensions: answerability, fidelity, question quality, and answer quality. Step 4: Overall Score – Calculate a weighted overall quality score (final_score) and categorize the scores (high / medium / low). Only high-scoring question-answer pairs are included in the final output. Samples deemed "low-quality question-answer pairs" in this layer are filtered out. The remaining qualified samples are aggregated into the bottom green module, outputting high-quality question-answer pair data as the final output.
[0106] Corresponding to the anchor-aware question-answer pair automatic generation method described in the above embodiments, the present invention also provides an anchor-aware question-answer pair automatic generation device.
[0107] Specifically, Figure 6 A schematic diagram of the structure of the question-answer pair automatic generation device based on anchor point awareness provided in an embodiment of the present invention is shown.
[0108] like Figure 6 As shown, the device includes: a semantic segmentation module 610, which performs semantic segmentation on the input text document to obtain at least one text block; a question construction module 620, which constructs a question by using key objects in each text block as anchors; wherein, when constructing a question, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited; an answer generation module 630, which generates an answer by combining the question as a query condition with the text block corresponding to the question, forming a question-answer pair; a quality assessment module 640, which performs quality assessment on the question-answer pairs, and removes question-answer pairs that contain referential expressions, have external dependencies, or have a comprehensive quality score lower than a preset threshold; and a question-answer pair output module 650, which outputs question-answer pairs that pass the quality assessment as training data.
[0109] In this embodiment, the semantic segmentation module 610 performs semantic segmentation on the input text document to obtain at least one text block. The question construction module 620 constructs questions by using key objects in each text block as anchors. During question construction, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited. The answer generation module 630 uses the question as a query condition and combines it with the corresponding text block to generate an answer, forming a question-answer pair. The quality assessment module 640 performs a quality assessment on the question-answer pairs, eliminating those containing referential expressions, having external dependencies, or whose overall quality score is below a preset threshold. Finally, the question-answer pair output module 650 outputs qualified question-answer pairs as training data. This device can automatically generate high-quality question-answer pairs from the original text document that are semantically complete, unambiguous in referential meaning, and independent of external context, significantly improving the accuracy of training data and the model fine-tuning effect. Simultaneously, through explicit anchor embedding and a multi-dimensional quality assessment mechanism, it effectively avoids information distortion, phantom answers, and context-dependent problems common in traditional automatic generation methods.
[0110] It should be noted that the anchor-aware question-answer pair automatic generation device provided in this embodiment of the invention can be referred to in correspondence with the anchor-aware question-answer pair automatic generation method described in the above embodiments, and will not be repeated here.
[0111] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7As shown, the electronic device may include a processor 710, a communications interface 720, a memory 730, and a communication bus 740, wherein the processor 710, communications interface 720, and memory 730 communicate with each other via the communication bus 740. The processor 710 can call logical instructions in the memory 730 to execute an anchor-aware question-answer pair automatic generation method. This method includes: semantically segmenting the input text document to obtain at least one text block; constructing questions using key objects in each text block as anchors; wherein, when constructing questions, the full name of the anchor is forcibly embedded into the question text, and the use of referential words is prohibited; using the question as a query condition, generating an answer by combining the text block corresponding to the question, forming a question-answer pair; performing quality evaluation on the question-answer pairs, eliminating question-answer pairs containing referential expressions, having external dependencies, or with a comprehensive quality score below a preset threshold; and outputting quality-evaluated question-answer pairs as training data.
[0112] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0113] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the anchor-aware question-answer pair automatic generation method provided by the above methods. The method includes: semantically segmenting an input text document to obtain at least one text block; constructing a question using key objects in each text block as anchors; wherein, when constructing the question, the full name of the anchor is forcibly embedded in the question text, and the use of referential words is prohibited; generating an answer by combining the question with the text block corresponding to the question, forming a question-answer pair; performing a quality assessment on the question-answer pair, and removing question-answer pairs that contain referential expressions, have external dependencies, or have a comprehensive quality score lower than a preset threshold; and outputting question-answer pairs that pass the quality assessment as training data.
[0114] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the anchor-aware question-answer pair automatic generation method provided by the above methods. The method includes: semantically segmenting an input text document to obtain at least one text block; constructing a question using key objects in each text block as anchors; wherein, when constructing the question, the full name of the anchor is forcibly embedded in the question text, and the use of referential words is prohibited; generating an answer by combining the question with the text block corresponding to the question, forming a question-answer pair; performing a quality assessment on the question-answer pair, and removing question-answer pairs that contain referential expressions, have external dependencies, or have a comprehensive quality score below a preset threshold; and outputting question-answer pairs that pass the quality assessment as training data.
[0115] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0116] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0117] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for automatically generating question-answer pairs based on anchor point awareness, characterized in that, include: The input text document is semantically segmented to obtain at least one text block; The key objects in each text block are used as anchors to construct questions; when constructing questions, the full name of the anchor is forced to be embedded in the question text, and the use of referential words is prohibited; Using the question as the query condition, and combining it with the corresponding text block, an answer is generated to form a question-answer pair; The question-and-answer pairs are evaluated for quality, and those containing referential expressions, having external dependencies, or having an overall quality score below a preset threshold are removed. Output question-answer pairs that pass the quality assessment as training data.
2. The method for automatically generating question-answer pairs based on anchor point awareness according to claim 1, characterized in that, The method of constructing a problem by using key objects in each text block as anchor points includes: Extract at least one key object from the text block as an anchor point; For each anchor point, an applicability judgment is made based on the preset problem type; For the applicable question type, a corresponding question is generated based on the combination of the anchor point and the question type.
3. The method for automatically generating question-answer pairs based on anchor point awareness according to claim 2, characterized in that, The preset question types include at least two of the following: fact extraction, mechanism explanation, design reasons, conditional constraints, limitation trade-offs, and comparative relationships.
4. The method for automatically generating question-answer pairs based on anchor point awareness according to claim 3, characterized in that, For each anchor point, the applicability judgment is performed based on a preset problem type, including: For each question type other than the fact extraction type, detect whether the text block contains keywords related to the question type; If no keywords are detected, the large language model is invoked to determine whether the text block is suitable for generating a question of the specified question type.
5. The method for automatically generating question-answer pairs based on anchor point awareness according to claim 1, characterized in that, The process of generating an answer by combining the question as a query condition with the corresponding text block to form a question-answer pair includes: Based on multiple different large language models, candidate answers are generated according to the question and the text block, respectively. The review model was used to score each candidate answer based on the dimensions of fidelity, accuracy, completeness, professionalism, independence, and fluency. The best candidate answer is selected as the final answer based on the scoring results, forming a question-answer pair.
6. The method for automatically generating question-answer pairs based on anchor point awareness according to claim 1, characterized in that, The quality assessment of the question-and-answer pairs includes: Detect whether the question-and-answer pair contains referential expressions; The large language model is used to determine whether the question-answer pair has external dependencies; the external dependencies include information referenced by the question-answer pair that is not explicitly contained in the corresponding text block, or the question-answer pair that requires content outside the text block to be understood; The large language model is invoked to score the question-answer pairs from the dimensions of answerability, fidelity, question quality, and answer quality, and a weighted comprehensive quality score is obtained.
7. The method for automatically generating question-answer pairs based on anchor point awareness according to claim 1, characterized in that, The step of semantically segmenting the input text document to obtain at least one text block includes: The text document is segmented using a sliding window based on a large language model, and semantically overlapping areas are preserved between adjacent windows to generate semantically coherent text blocks.
8. An automatic question-answer pair generation device based on anchor point awareness, characterized in that, include: The semantic chunking module performs semantic chunking on the input text document to obtain at least one text block; The question construction module semantically constructs questions by using key objects in each text block as anchors; when constructing questions, the full name of the anchor is forcibly embedded in the question text, and the use of referential words is prohibited; The answer generation module is used to generate an answer by combining the question as the query condition with the text block corresponding to the question, thus forming a question-answer pair; The quality assessment module is used to assess the quality of the question-answer pairs and remove those that contain referential expressions, have external dependencies, or have a comprehensive quality score below a preset threshold. The question-answer pair output module is used to output question-answer pairs that pass the quality assessment as training data.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the anchor-aware question-answer pair automatic generation method as described in any one of claims 1 to 7.
10. A non-transitory 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 anchor-aware question-answer pair automatic generation method as described in any one of claims 1 to 7.