Question and answer generation method and device based on reference verification and similarity constraint, medium and program product
Through the citation verification and similarity constraint mechanism, the problems of inconsistent citations and content distortion in question and answer generation are solved, ensuring the source credibility and semantic accuracy of the generated question and answer results. It is suitable for high-reliability question and answer application scenarios such as regulatory interpretation, corporate knowledge question and answer, and intelligent customer service.
Patent Information
- Application Number
- CN202511115058.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-11
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2045-08-11
AI Technical Summary
Existing technologies have inconsistent citations and distorted content generation in the question and answer generation process, which makes the question and answer results prone to hallucinatory errors or semantic disconnection, and cannot meet the requirements of high-trust, auditable and traceable enterprise-level applications.
By introducing reference verification and similarity constraint mechanisms, we ensure that the generated reference content is consistent with the original text, and control the answer generation process through semantic similarity scoring, including literal and hash-level consistency verification, as well as a dynamic iterative generation mechanism, to ensure the credibility and semantic relevance of the question and answer results.
It significantly improves the traceability, accuracy, and semantic relevance of question-and-answer results, and is suitable for high-reliability question-and-answer application scenarios such as regulatory interpretation, enterprise knowledge question-and-answer, and intelligent customer service.
Smart Images

Figure CN120611032A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answer generation method, device, medium, and program product based on reference verification and similarity constraints. Background Art
[0002] With the widespread adoption of large language models (LLMs) in document question-answering systems, the Retrieval Augmented Generation (RAG) architecture has become a mainstream solution in the industry. This approach typically retrieves the original document before generating an answer, extracting relevant paragraphs from the document as input context for the large language model. This narrows the model's reasoning space and reduces the probability of incorrect answers.
[0003] However, the RAG solution still has the following problems in practical applications: Citation uncertainty problem: Although the model claims that its output content comes from the retrieved document fragments, it lacks strong constraints on the one-to-one correspondence between the cited content and the original document. It is easy for citations to be rewritten, spliced, or even fabricated, resulting in a lack of verifiability in the generated results.
[0004] Insufficient answer relevance: The relevance between the generated answer and the cited content is difficult to guarantee. Even if the model correctly cites the document content, the generated answer may still have semantic jumps or logical distortions, making it impossible to ensure high consistency with the cited content, which can lead to factual deviations or "hallucination" problems.
[0005] Therefore, existing technologies have not established an end-to-end quality control mechanism from reference generation to answer output. The current document-generated question-answering system still cannot meet the requirements of highly reliable, auditable, and traceable enterprise-level applications. Summary of the Invention
[0006] In response to the shortcomings of the existing technology, the present application provides a question and answer generation method, device, medium and program product based on reference verification and similarity constraints, which is at least used to solve the problem that the existing technology has inconsistent references and distorted content generation in the question and answer generation process, which leads to hallucinatory errors or semantic disconnection in the question and answer results.
[0007] In order to achieve the above objectives and other advantages, some embodiments of the present application provide the following aspects: In a first aspect, some embodiments of the present application provide a question-answer generation method based on reference verification and similarity constraints, including: Get the document content related to the question entered by the user; Based on the document content, a reference list is generated using a generation model, wherein the reference list includes one or more reference contents, each of which is composed of an original text segment extracted from the document content, and rewriting of the original text segment is not allowed during the generation process; Perform consistency verification on each reference in the reference list and the corresponding original text segment in the document content. If any reference fails the verification, the reference list is regenerated until all references in the reference list pass the consistency verification. On the basis that the reference list passes the consistency verification, generating candidate answers based on the question input by the user, calculating the semantic similarity between the candidate answers and the reference list, and obtaining a similarity score value; Comparing the similarity score with a preset similarity threshold; if the similarity score is lower than the similarity threshold, re-performing the reference list generation and consistency verification process, as well as the candidate answer generation process, until the reference list passes the consistency verification and the similarity score meets the similarity threshold requirement; Output candidate answers that meet the reference consistency verification and similarity requirements, and together with the question entered by the user, form a question-answer pair.
[0008] In a second aspect, some embodiments of the present application further provide an electronic device, comprising: One or more processors; and a memory storing computer program instructions, wherein when the computer program instructions are executed, the processors execute any one of the above-described question-answer generation methods based on reference verification and similarity constraints.
[0009] In a third aspect, some embodiments of the present application further provide a computer-readable storage medium having stored thereon a computer program and / or instructions, which, when executed by a processor, implements a question-and-answer generation method based on reference verification and similarity constraints as described above.
[0010] In a fourth aspect, some embodiments of the present application also provide a computer program product, including a computer program and / or instructions, which, when executed by a processor, implements a question-and-answer generation method based on reference verification and similarity constraints as described above.
[0011] Compared with the related art, in the solution provided by the embodiment of the present application, after the generation model outputs the quoted content, the system verifies the literal or hash level consistency of each quote with the original document to ensure that the quoted source has not been rewritten or misused, avoids the flow of "hallucination" content into the question and answer results, and enhances the credibility of the question and answer. After the candidate answer is generated, the semantic similarity calculation is used to measure whether the answer content maintains sufficient semantic fit with the quoted content, effectively suppressing the output of irrelevant or weakly relevant answers. Therefore, the introduction of the reference consistency verification mechanism and the semantic similarity scoring constraint mechanism significantly improves the traceability, accuracy and semantic relevance of the answer content in the process of generating question and answer results. In addition, the solution of the present application uses a dynamic iterative generation mechanism to automatically retry and adjust the generation strategy when the reference or semantics do not meet the standards, ensuring that the final output question and answer pair meets the preset standards in both source credibility and semantic accuracy. It is particularly suitable for high-reliability question and answer application scenarios such as legal interpretation, corporate knowledge question and answer, intelligent customer service, and knowledge management. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other implementation methods can be obtained based on these drawings without paying any creative work.
[0013] Figure 1 This is a flowchart of a question-answer generation method based on reference verification and similarity constraints provided by an embodiment of the present application; Figure 2 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0014] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0015] First embodiment The first embodiment of the present application relates to a question-answer generation method based on reference verification and similarity constraint, referring to Figure 1 As shown, the method may include the following steps: Step S1: Obtain document content related to the question input by the user.
[0016] Specifically, regarding step S1, user-entered questions may include, but are not limited to, factual questions, explanation questions, procedural questions, data extraction questions, and judgment and reasoning questions in natural language. Document content may include: structured / semi-structured policy documents, business documents in natural language format, knowledge base materials, internal company documents, and any uploaded user-defined text.
[0017] Receive natural language questions input by users and perform language preprocessing operations on the questions, including but not limited to word segmentation, keyword extraction, semantic parsing, and question type identification, to obtain the core intent and key expressions of the question; then, search the preset document library based on the extracted semantic features to filter out the target document set that has semantic relevance to the question, which may include one or more documents. For example, for the question input by the user, "What is the return and exchange process for this product?", the system can retrieve the relevant section "Return and Exchange Instructions" from the product user agreement, help center documents, etc., and further divide the section into multiple content units containing location information and text hash values, which serve as the content source for subsequent reference generation and verification.
[0018] It should be noted that in practical applications, the method of this embodiment not only supports processing a single natural language question, but can also be expanded to support the parallel processing of multiple natural language questions or dialogue context modeling (for example, in batch processing or multi-round dialogues). By performing reference generation and verification for each question, the reliability and traceability of the generated question-answer pairs are ensured. This is suitable for scenarios where high-quality question-answer pairs need to be generated in batches in question-answering robots or intelligent document parsing systems.
[0019] Step S2: Based on the document content, a reference list is generated using a generation model. The reference list includes one or more reference contents. Each reference content is composed of an original text segment extracted from the document content, and rewriting of the original text segment is not allowed during the generation process.
[0020] For step S2, specifically, each question corresponds to a reference list to ensure that the reference content is highly relevant to the semantics of the question. The structure of the application list may include: reference content (original text fragments extracted directly from the document, which cannot be rewritten by the model), location information (including page number, paragraph number, character starting offset position, etc.), unique identifier, optional hash checksum, format tags (such as markdown reference symbols, structured JSON tags). The generative model can be a large language model that has been fine-tuned by instructions, which can generate structured text content based on the input natural language instructions, such as GPT-type models, T5-type models or other language models that support question-answering generation and content extraction functions. It can also use multimodal generative models such as GPT-4V, BLIP, MiniGPT with image and text mixing capabilities, and support input documents containing non-pure text content such as images or tables. The reference content must be the original sentence or paragraph extracted directly from the document. The model is not allowed to process, generate or rewrite it by itself to ensure its authenticity and traceability.
[0021] Step S3: Perform consistency verification on each reference content in the reference list and the corresponding original text segment in the document content. If any reference content fails the verification, the reference list will be regenerated until all reference contents in the reference list pass the consistency verification.
[0022] For step S3, specifically, for each reference content in the reference list, its accompanying location information (including page number, paragraph number, character offset, etc.) is extracted to accurately locate the corresponding original text segment in the document content; a consistency check is performed based on the located original text segment and the reference content, and the consistency check includes literal comparison and hash comparison. Literal comparison refers to directly comparing the string content of the reference content and the original text segment to see if they are completely consistent; hash comparison uses a text hash algorithm such as SHA-256 to calculate the hash summary values of the reference content and the original text segment respectively, and determine whether they are consistent. If there is any inconsistency between the cited content and the original text fragment (such as the text is rewritten, truncated or spliced), the current citation list is determined to have failed the consistency verification, triggering the re-execution of the citation generation process; when regenerating the citation list, the content characteristics of the current failed citation, the error type (such as position offset, splicing error, inconsistent summary) and other information can be combined to construct a feedback signal, dynamically optimize the prompt instructions of the next round of generation model, and appropriately adjust the generation constraints, citation style or content truncation range, so as to improve the consistency and verifiability of the citation generation results; this process continues to iterate until all the cited content in the generated citation list passes the consistency check, ensuring that all cited content is true, complete, and unrewritten original text fragments, effectively supporting the traceability verification and accuracy assurance of subsequent question and answer content.
[0023] Step S4: On the basis that the reference list passes the consistency verification, candidate answers are generated based on the question input by the user, and the semantic similarity between the candidate answers and the reference list is calculated to obtain a similarity score value.
[0024] Specifically, in step S4, based on the question input by the user, the language generation model is invoked to generate a natural language answer under preset generation instructions. These instructions may include information about the context type of the question, answer style restrictions, output format constraints, and other factors, guiding the model to generate candidate answers that meet semantic requirements according to established strategies. The candidate answer generation process can reuse the same large language model (LLM) or lightweight instruction fine-tuning model used for reference list generation, that is, the reference generation and answer generation tasks are unified within the same model system. This avoids the resource overhead caused by frequently switching models or calling different interfaces between reference generation and answer generation, improving overall processing efficiency.
[0025] After candidate answers are generated, the references in the reference list serve as the baseline for semantic verification. Using a semantic vector model (such as the SBERT model), they are matched against the candidate answers to calculate an overall semantic similarity score. This is used to assess whether the answer content is highly consistent with the document's basis, thereby controlling the factual reliability of the output. For example, after generating the answer "Users can apply for returns or exchanges within 7 days," the system semantically compares this answer with multiple original text fragments in the reference list, resulting in a similarity score of 0.91. If the similarity threshold is met, the final question-and-answer result is output.
[0026] Step S5: Compare the similarity score value with the preset similarity threshold. If the similarity score value is lower than the similarity threshold, re-execute the reference list generation and consistency verification process, as well as the candidate answer generation process, until the reference list passes the consistency verification and the similarity score value meets the similarity threshold requirement.
[0027] For step S5, specifically, the similarity score between the candidate answer and the reference content is compared with a preset similarity threshold to determine whether the candidate answer has sufficient semantic relevance. For example, when the set similarity threshold is 0.85, if the similarity score is lower than the similarity threshold, it is considered that the candidate answer fails to fully reflect the core semantic information expressed by the reference content and needs to be regenerated. When the similarity score does not meet the currently calculated dynamic threshold, the system will trigger the regeneration and consistency verification process of the reference list, as well as the regeneration process of the candidate answer. At the same time, the reasons for the failure of the previous round of comparison (such as lengthy answers, deviations in semantic expression, insufficient reference coverage, etc.) can also be used as feedback signals to adjust the prompt constraint strategy of the generation model, such as limiting the output length, strengthening the reference density constraint, or optimizing the context input method, so as to improve the semantic convergence and compliance rate of the subsequent question and answer generation process, reduce the probability of misjudgment due to differences in language style, and thus improve the stability and effectiveness of the overall generation results.
[0028] Step S6: Output candidate answers that meet the reference consistency verification and similarity requirements, and together with the question input by the user, form a question-answer pair.
[0029] For step S6, specifically, after the candidate answer meets the reference consistency verification and semantic similarity score threshold requirements, the system will structure the candidate answer and the question input by the original user to form a final question-answer pair, and assign a unique identification number to support subsequent calls and management. The question-answer pair can be encapsulated into a standardized output format, including but not limited to JSON format, Markdown format, or a preset question-answer platform custom data structure to support visual display and programmatic access in application scenarios such as search engine interfaces, intelligent question-answer platforms, and document intelligent assistants. The system can attach the location information, similarity score value, and verification status field of the reference list to the question-answer output to support subsequent auditing, debugging, or multiple rounds of interactive retrieval processes, thereby improving the traceability and interpretability of the question-answer results.
[0030] Compared with the related art, in the solution provided by the embodiment of the present application, after the generation model outputs the quoted content, the system verifies the literal or hash level consistency of each quote with the original document to ensure that the quoted source has not been rewritten or misused, avoids the flow of "hallucination" content into the question and answer results, and enhances the credibility of the question and answer. After the candidate answer is generated, the semantic similarity calculation is used to measure whether the answer content maintains sufficient semantic fit with the quoted content, effectively suppressing the output of irrelevant or weakly relevant answers. Therefore, the introduction of the reference consistency verification mechanism and the semantic similarity scoring constraint mechanism significantly improves the traceability, accuracy and semantic relevance of the answer content in the process of generating question and answer results. In addition, the solution of the present application uses a dynamic iterative generation mechanism to automatically retry and adjust the generation strategy when the reference or semantics do not meet the standards, ensuring that the final output question and answer pair meets the preset standards in both source credibility and semantic accuracy. It is particularly suitable for high-reliability question and answer application scenarios such as legal interpretation, corporate knowledge question and answer, intelligent customer service, and knowledge management.
[0031] Second embodiment The second embodiment of the present application relates to a question-answer generation method based on reference verification and similarity constraints. The second embodiment is an improvement on the first embodiment. The specific improvement is that: in the second embodiment of the present application, a document structured preprocessing mechanism is introduced. That is, before executing step S2, the document content is structured preprocessed, specifically including: Step A1: Divide the document content into paragraphs, sentences or logical levels, extract the text content of each content unit based on the document layout information and semantic tags, and attach location information to each content unit. The attached location information includes page number, paragraph number or line number, and the starting character offset position in the document.
[0032] Specifically, the system first performs a content division operation on the input document content. Division methods can include paragraph division, sentence division, or logical level division. Paragraph division: Based on the natural paragraph boundaries in the document, such as paragraph marks or paragraph indentation symbols. Sentence division: Each paragraph of text is further divided into sentence-level units with the help of sentence rules or natural language processing models (such as dependency syntactic analysis, BERT sentence model). Logical level division: Logical units such as chapters, sections, and subsections are identified based on the document directory index structure and title numbering style.
[0033] After completing the content division, the system further combines the document's layout structure information (such as PDF page numbers, Word styles, HTML tags) with semantic markup information (such as paragraph start or title semantics identified by the natural language model) to extract the plain text content of each content unit. For example, for PDF format documents, the page number, font style, paragraph layout and other information in its metadata can be parsed; for Office documents (such as Word), its paragraph style, title tags and other structural tags can be used; for HTML format web pages, tags (such as <h1>、 、 ) to position the content boundaries.
[0034] While extracting each content unit, the system adds location information to the unit. The location information may include: page number (identifying the page number of the document where the content unit is located), paragraph number or line number (paragraph number or text line number in the page or full text), character starting offset position (the starting index value of the content unit in the full text character stream). The additional location information is bound to the original text to form a structured content unit, which is used for accurate mapping for subsequent citation consistency verification to ensure that the referenced text can be effectively located and verified.
[0035] Step A2: Generate a unique identifier for each content unit, calculate the corresponding text hash digest value, and establish a mapping index structure among the unique identifier, text hash digest value, and original text content.
[0036] For each content unit obtained in step A1, a unique identifier is further generated to uniquely locate and track the content unit. This unique identifier can be generated using one of the following methods: encoding the content's location information within the document, using the content's hierarchical number within the document structure, or directly generating a globally unique identifier for each content unit.
[0037] After generating the identifier, the system also performs a hash calculation operation on the text of each content unit. Specifically, a hash algorithm such as SHA-256 or MD5 is used to generate a summary of the text to form an irreversible hash value that strictly corresponds to the content. This hash summary can be used to subsequently verify whether the generated reference is consistent with the original content. If the document content is modified, the difference can be quickly located by comparing the hash value. A mapping relationship is established between the generated unique identifier, the text hash summary value, and the original text content of the unit to construct a ternary mapping index structure. This mapping structure can be organized using key-value storage (such as a hash table or a key-value database). In the question-and-answer generation task, when the model outputs a piece of quoted content, the system can find the corresponding original text through its identifier and verify its consistency based on the hash summary, thereby realizing a mechanism that the reference cannot be tampered with.
[0038] Step A3: Construct a document structure tree to record the hierarchical relationship and logical context path between each content unit. The document structure tree includes chapter title path, parent-child structure identifier and logical sequence information.
[0039] Specifically, after completing the division and identification of content units and the construction of abstract indexes, the system further models the structural hierarchy of the document to form a document structure tree, which is used to comprehensively represent the organizational relationship and context path between each content unit, thereby providing structured support for citation selection, contextual reasoning and structured retrieval.
[0040] A document structure tree organizes a document's content units into a directed tree (or multi-branch tree), where each node represents a content unit; edges indicate hierarchical or subordinate relationships, such as a paragraph belonging to a chapter, or a subsection being a child of a larger section. The root node of the tree is the logical starting point of the entire document (such as a title page or overview), and the leaf nodes correspond to indivisible basic content units (such as single sentences or text fragments). For each structure tree node, its structural attributes are recorded, such as the chapter title path, parent-child structure identifiers, and logical order information. The document structure tree can be constructed by automatically extracting chapter nodes based on the document's table of contents and title hierarchy, or by using natural language processing models to assist in determining the subordinate relationships between paragraphs. For text without a clear table of contents (such as PDFs or OCR scans), the structure can be inferred by combining typographical features such as font size, indentation, and numbering patterns.
[0041] By constructing a document structure tree, during the reference extraction stage, the context of the reference content can be located based on the chapter path and logical order; when generating answers, the context path provided by the document structure tree can be used as a location hint to assist the model in generating more logically coherent answers; during reference verification, the reliability of the reference and the consistency of the context can be improved through parent node comparison or cross-validation of nodes at the same level; and for batch generation of question-answer pairs for multiple questions, the document structure tree can be used to batch locate and cluster related paragraphs, thereby improving generation efficiency.
[0042] By introducing a document structured preprocessing mechanism, on the one hand, the document content is refined into structured content units with unique identifiers, location information, and hash digest values, so that the citation generation module can accurately associate the original text fragments when outputting the citation content; in the subsequent consistency verification stage, by comparing the hash digest or location markers, it can quickly determine whether the citation content has been rewritten, truncated, or spliced, significantly improving the accuracy and traceability of the citation. On the other hand, with the help of the document structure tree, the hierarchical relationship and context path between content units are modeled. In the citation generation stage, the model can be assisted by prompt information such as chapter context and parent-child structure to screen citation fragments with more coherent context and more complete semantics, thereby enhancing the semantic consistency and context adaptability of the citation content and avoiding semantic deviations caused by quoting citation fragments out of context.
[0043] The index structure and hierarchical relationship established by structured preprocessing also support the rapid positioning and batch aggregation of reference content. In scenarios such as multi-round question and answer, batch generation, or intelligent summarization, multiple relevant references can be efficiently extracted based on the semantics of the question, significantly improving the overall efficiency of the question and answer generation system and the automation capability of reference calls.
[0044] Furthermore, after the document content is structurally preprocessed, this embodiment further provides a specific implementation method for generating a reference list based on a mandatory reference prompt template, that is, step S2 may further include the following steps: Step S201: in the prompt instruction for generating a reference list input to the generation model, a mandatory reference prompt template including a format control mark is set, and the mandatory reference prompt template is used to require that a reference list must be generated first in the output result.
[0045] Specifically, before calling the generation model to generate the reference list, the system constructs and injects a prompt instruction. This prompt instruction embeds a mandatory reference format template to standardize the content format of the model output and explicitly requires it to prioritize the output of the reference content list. This template has the following characteristic elements: Formatting control tags: These guide the generated model to explicitly mark citations in the output using predefined structural tags. For example, you can use formats such as "[begin citation]...[end citation]", JSON object blocks, and Markdown citation blocks to clearly delineate the start and end boundaries of each citation.
[0046] Location information requirements: Each citation must be accompanied by a structured location information field in the source document, such as page number, paragraph number or line number, character starting offset, unique identifier, etc.
[0047] Content source constraints: The template explicitly requires that the quoted content must be strictly extracted from the original text content in the structured document. Any rewriting, abbreviation, splicing or reconstruction based on model understanding is not allowed.
[0048] Quantity range and style restrictions: Based on the specific application scenario, you can use the template to set the quantity range of citations generated, the maximum text length of each citation, and whether to allow citations to span multiple logical units or sentences, and other style restrictions.
[0049] This template reduces the risk of mismatch or overwriting when the model freely generates references through rigid format control and explicit reference requirements.
[0050] Step S202: The generation model filters original text segments that are semantically relevant to the question from the structured document content based on the question input by the user, and outputs one or more reference contents that are formatted and annotated with location information according to the mandatory reference prompt template to generate a reference list. The original text segment includes one or more content units, or a continuous text segment within at least one content unit.
[0051] Specifically, after receiving the prompt instruction, the generative model performs a semantic comparison between the question input by the user and the various content units in the structured document content, and screens out content units or their internal fragments that are closely related to the semantics of the question through built-in attention mechanisms, embedding vector similarity, etc.
[0052] The model formats the selected source text fragment according to the prompt template requirements, such as retaining the original text and prohibiting any rewriting or truncation; adding source location markers such as page numbers, paragraph numbers, and character offsets; and if the extracted fragment is a continuous fragment within a content unit, retaining the unit number and recording the offset range. The formatted reference content is output as a list structure, which serves as the reference list corresponding to the current question.
[0053] Each reference content in the reference list can be: a complete content unit, or a continuous sentence in a content unit, or a logical segment formed by splicing multiple content units.
[0054] By driving the generation of citation lists based on a mandatory citation prompt template, the output structure of the generative model is explicitly standardized, ensuring that citation content has clear start and end boundaries and structured properties. The accompanying metadata, such as page numbers, paragraph numbers, and character offsets, can be directly mapped to the document index structure constructed during the preprocessing phase, enabling rapid retrieval of the original text and preventing model misquotes or out-of-context citations. Furthermore, the template stipulates that citation content must be a strict excerpt of the original document, strictly prohibiting rewriting, splicing, or linguistic reconstruction. This eliminates the semantic drift, factual errors, or difficulty in verification that can arise from the free generation of the model, significantly improving the authenticity and auditability of citations. This is particularly true in highly audited scenarios (such as law, healthcare, and finance), ensuring the traceability and verifiability of the answer source. Therefore, combining structured documents with a semantic screening mechanism, the generative model can accurately extract original text fragments that are strongly related to the question under the constraints of the template, improving the relevance and accuracy of the citation content.
[0055] Third embodiment The third embodiment of the present application relates to a question-answer generation method based on reference verification and similarity constraints. The third embodiment is an improvement on the first embodiment. Specifically, the third embodiment provides a specific implementation method for optimizing the generation of a reference list based on dynamic verification. That is, step S3 can further include the following steps: Step S301: for each reference content in the reference list, locate the corresponding original text segment in the document content based on the position information carried; Step S302: Based on the original text segment and the quoted content, dynamically select a literal comparison or a hash comparison method to perform consistency verification to determine whether the quoted content has been tampered with, added, deleted, or rewritten at the text level; Step S303: When any reference content in the reference list fails the consistency check, the reference list generation process is triggered to be re-executed, and a prompt instruction for generating the reference list is resent to the generation model; Step S304: The prompt instruction dynamically adjusts the format control requirements, reference strategy parameters or generates constraint rules according to the type, location and error characteristics of the previous round of reference verification failure, thereby guiding the generation model to output a new reference list until all reference contents in the reference list pass the consistency verification.
[0056] Specifically, each reference is accompanied by a location information field generated by a structured preprocessing mechanism during the generation process, such as the page number, paragraph or line number, character start offset, and unique identifier. The system uses this location information as an index key to quickly locate the corresponding content unit within the index structure constructed from the structured document content.
[0057] If the referenced content covers a complete content unit, the system can directly use the original text of the content unit as the comparison source; if the referenced content involves a continuous segment (such as a partial sentence) in a content unit, the system combines the starting offset information to accurately extract the corresponding substring content in the original text. If the referenced content involves a logical segment formed by the splicing of multiple content units, the system will retrieve the original text of each content unit in turn based on the multiple unique identifiers contained in the position information, and splice them together in the order of the documents to form a comparison segment. If character offset information or clause-level offset markers exist in the adjacent spliced content units, sub-content clipping will be performed on the first and last content respectively to accurately extract the original text segment corresponding to the referenced content.
[0058] After locating the reference content and the original text, the system performs a consistency check on the two to identify whether the reference has been tampered with, rewritten, or formatted. This includes: Literal matching: The system uses a character-by-character comparison strategy to determine whether the original text string and the quoted text are completely consistent, including punctuation, spaces, capitalization, etc. This applies to scenarios where the quoted content is a single sentence or a complete paragraph; the text is well-formatted without line breaks or encoding disturbances; and the user or model output is a standard copy-and-paste.
[0059] Hash comparison: The system calculates cryptographic hash values (such as SHA-256 or MD5) for both the original and the quoted content and compares them for consistency. This method is unaffected by formatting differences such as spaces and line breaks, providing greater fault tolerance. It is applicable in scenarios where the quote is a logical fragment formed by concatenating multiple content units; where the text contains line breaks, indentations, or encoding formatting variations; and where character-level changes are introduced when exporting to unstructured formats (such as PDF to HTML).
[0060] The system introduces a comprehensive validity check for the reference list, predicated on the validation of all references in the reference list. If any reference entry fails the consistency check, the current reference list is deemed to have a potential risk of content tampering, truncation, or mismatching, and the entire set of references is deemed invalid. To ensure the verifiability and credibility of the final Q&A results, the system immediately interrupts the current Q&A generation process and initiates the next round of automatic reference list regeneration. During this process, the system resends the reference list generation prompt to the generation model and re-initiates the reference extraction request. At this point, the system records the specific information about the reference content that failed verification (including failure type, reference location, formatting errors, text inconsistencies, etc.).
[0061] Based on the specific information of the previous round of reference content verification failure, the prompt instructions are optimized and dynamically adjusted to improve the quality of the new round of generated results and the verification pass rate. This dynamic adjustment includes the following strategies: Adjustment of format control requirements: Strengthen the filling requirements of boundary markers and location information fields in the reference template, such as adding explicit prompts for [Reference Start] and [Reference End], or adding mandatory verification rules for fields such as unique identifier number and character offset.
[0062] Updated citation strategy parameters: Adjust the scope of the model's citation content extraction, such as limiting the maximum length of a single citation, avoiding cross-segment citations, and disabling fragment splicing, to prevent accidental cutting and rewriting of content.
[0063] Strengthened generation constraints: Added soft and hard constraints such as "character-level exact match", "references must be accompanied by complete location information", and "maintain the semantic boundaries of the original text" to guide the model to strictly adhere to the document structure and original content during generation.
[0064] The above adjustment strategies can be implemented through programmatic template reconstruction, model prefix injection, prompt engineering enhancements, and other methods to ensure that the next round of model generation output is more standardized, compliant, and verifiable. To ensure that all reference content meets consistency requirements, the system has established an automatic iteration mechanism. After each round of reference generation, a consistency check is performed. If inconsistent references exist, the prompt instruction parameters are dynamically adjusted according to the error type and the reference content is regenerated. This iterative process continues until the entire reference list passes verification, ensuring that the reference content is authentic, complete, and traceable.
[0065] It is not difficult to see that in the embodiment of the present application, by introducing a reference list optimization generation mechanism driven by dynamic verification, the consistency verification of the generated reference content is achieved one by one, and the regeneration process is automatically triggered when problems such as reference tampering, trimming or forgery are found. This mechanism supports dynamic adjustment of prompt instructions and generation constraint parameters according to the type of reference error, and continuously iterates the generation and verification process until all reference content passes the consistency check. This can effectively prevent the generation of false references, ensure that the text quoted in the question and answer is true, complete, and not tampered with, and significantly improve the traceability, reference credibility and content accuracy of the question and answer system.
[0066] It should be noted that the third embodiment of the present application may also be an improvement based on any one or more of the first to second embodiments.
[0067] Fourth embodiment The fourth embodiment of the present application relates to a question-answer generation method based on reference verification and similarity constraints. The fourth embodiment is an improvement on the first embodiment. Specifically, the fourth embodiment provides a specific implementation method for weighted fusion calculation of semantic similarity for evaluation, that is, step S4 can further include the following steps: Step S401: Input the reference content and candidate answers in the reference list into a pre-trained semantic encoding model to generate their respective semantic vectors; Step S402: Calculating the semantic similarity score between the candidate answer and each quoted content based on the cosine similarity between the semantic vector of the candidate answer and the semantic vector of each quoted content; Step S403: The semantic similarity scores are integrated according to a preset weighting strategy to calculate the overall semantic similarity score between the candidate answer and the reference list. The weighting strategy includes determining the weight coefficient of each reference content based on at least one indicator of the position information of the reference content in the original text, the text length, and the text density.
[0068] Specifically, the system inputs the candidate answer and each quote in the reference list into a pre-trained semantic encoding model (such as Sentence-BERT, RoBERTa, etc.) to extract their corresponding semantic vectors. The semantic vector is the expression of the original natural language in a high-dimensional space, which can capture deep semantic features and support sophisticated similarity calculations. For each quote in the reference list, , generate its semantic vector , and the semantic vector of the candidate answer .
[0069] Calculate the cosine similarity between the candidate answer and each quote:
[0070] in, Indicates the candidate answer and The semantic similarity score between the citations reflects the closeness of their semantic expressions; Represents the dot product of two vectors, which is used to measure their similarity in direction; Represent the candidate answer semantic vector and The modulus of the semantic vector of the reference content.
[0071] In order to comprehensively measure whether the candidate answers fully cover all the referenced content, the system will score each similarity Perform weighted fusion according to the importance of the cited content and calculate the overall similarity score :
[0072] in, For the The weight coefficient of the cited content satisfies .
[0073] The weighting coefficient can be determined based on the following dimensions: Citation location information: Citations located in key locations in the original text, such as core paragraphs, abstracts, and conclusions, are given higher weight. Text length indicator: The longer the quoted content, the higher the information carrying capacity, and the corresponding weight can be increased; Information density index: Citations with higher number of keywords, entity density, or term coverage per unit length are given greater weight; Structural factors: citations from chapter headings or higher-level structural paragraphs can be given higher weights; Manual or heuristic rules: such as prioritizing the weight of citations that are highly relevant to the question semantics.
[0074] Through the above fusion strategy, the system achieves a global quantitative evaluation of the semantic matching degree between the candidate answer and the entire reference set, rather than relying on a single reference matching result.
[0075] It is not difficult to see that in the embodiment of the present application, by introducing a similarity evaluation mechanism based on semantic vectors and combining it with a weighted fusion strategy, a refined evaluation of the semantic consistency between candidate answers and the quoted content is performed, which significantly improves the reliability and relevance of the citation-driven question and answer generation results. Compared with the solution that relies solely on text-level comparison, this embodiment can effectively identify whether the candidate answer truly matches the semantics of the quoted content, avoid superficial associations or misuse of original citations, enhance the question and answer system's control over the consistency of semantic understanding and evidence support, and help improve the credibility and review traceability of the final question and answer pair.
[0076] It should be noted that the fourth embodiment of the present application may also be an improvement based on any one or more of the first to third embodiments.
[0077] Fifth embodiment The fifth embodiment of the present application relates to a question-answer generation method based on reference verification and similarity constraints. The fifth embodiment is an improvement on the first embodiment. Specifically, the improvement is as follows: In the fourth embodiment of the present application, a specific implementation method for question-answer quality control driven by a dynamic adjustment mechanism of a similarity threshold is provided, that is, step S5 can further include the following steps: Step S501: constructing a similarity threshold adjustment function based on the text length and semantic compression rate of the candidate answer, the number of references in the reference list, the semantic density, semantic complexity, semantic dispersion and context closeness of the references; Step S502: dynamically adjusting the preset basic threshold interval using an adjustment function to output a currently applicable semantic similarity threshold; Step S503: Compare the similarity score value with the currently generated semantic similarity threshold. If the similarity score value is lower than the semantic similarity threshold, it is determined that the semantic relevance of the current question and answer result is insufficient, triggering the re-execution of the entire process of reference list generation, reference consistency verification and candidate answer generation.
[0078] Specifically, before performing semantic similarity assessment, the system extracts several key feature variables as input factors. These include the candidate answer's text length, semantic compression ratio, the number of citations in the reference list, semantic density, semantic complexity, semantic dispersion, and contextual closeness. Text length reflects the answer's semantic carrying capacity; semantic compression ratio indicates the degree to which the candidate answer compresses the original textual information; semantic density and complexity assess the expressive strength and comprehension difficulty of the citation; semantic dispersion measures the semantic consistency between citation fragments; and contextual closeness reflects the structural proximity between the citation and the candidate answer in the original document. These feature variables are normalized and form the input vector of the adjustment function.
[0079] The system feeds these input factors into a threshold adjustment function to generate a dynamic threshold. This adjustment function, which can employ a weighted linear model or a lightweight neural network structure, fuses the original base threshold (e.g., 0.85) with the adjusted influence of each input factor to output the currently applicable semantic similarity threshold. This threshold dynamically changes during each round of the question-answering task based on contextual semantic conditions, allowing for a more accurate assessment of the semantic quality of candidate answers.
[0080] The system compares the similarity score with the currently generated dynamic threshold. If the score is lower than the threshold, it determines that the semantic relevance of the current question and answer result is insufficient, triggering the re-execution of processes such as reference list generation, reference consistency verification, and answer generation. It also records failure information to continuously optimize the adjustment strategy, realizing an adaptive question and answer generation control mechanism based on multi-factor input and feedback drive.
[0081] Furthermore, the adjustment mechanism of the adjustment function includes: feedback optimization based on the failure information of the previous round of semantic similarity score that did not meet the semantic similarity threshold, dynamically adjusting the generation constraint parameters, the screening range of the reference content and the semantic concentration ratio in the candidate answer generation process, so as to enhance the semantic convergence and similarity compliance between the candidate answers and the reference content in the question and answer generation process.
[0082] Specifically, when the semantic similarity score between the candidate answer and the quoted content does not reach the currently set semantic similarity threshold, the system will judge the generation result of this round as a failure and extract the failure information as feedback input. The failure information includes but is not limited to: the position of the quoted fragment that fails to pass the threshold judgment, the deviation amplitude of the similarity score, the semantic divergence characteristics between the quoted content and the answer, the context structure position of the semantic drift, etc.
[0083] Driven by a feedback mechanism, the system automatically and dynamically adjusts multiple parameter paths in the question-answer generation process based on the aforementioned failure information. The adjustment strategy includes the following three aspects: Generation constraint parameter adjustment: Adjust the parameters of the candidate answer generation model, including output length limit, context coverage, level of abstraction and refinement, tone control (such as emphasis on quotations), etc., to make the generation results more focused on the core semantics expressed by the quoted content.
[0084] Optimize the scope of citation content screening: Adjust the content screening strategy for the next round of citation list generation. For example, increase the weight priority of semantic similarity or structural proximity during citation screening, narrow the candidate area, or redefine the semantic search window to select citation content that is more relevant to the question and more consistent with the answer.
[0085] Semantic Condensation Ratio Control: Dynamically control the summary level or retention granularity of the cited content, such as reducing the participation ratio of redundant sentences and increasing the retention ratio of key sentences, thereby improving the overall semantic expression density and information alignment of the quoted fragment.
[0086] Through the above-mentioned feedback optimization mechanism, the adjustment function realizes the coordinated optimization of generation control parameters and citation strategies to enhance the semantic convergence between candidate answers and cited content, improves the ability of the next round of question and answer generation results to pass the semantic similarity verification, and ensures that the final output results meet the quality standards set by the system in terms of content credibility and semantic consistency.
[0087] It is not difficult to see that in the embodiment of the present application, by introducing a control mechanism based on the dynamic threshold adjustment of semantic similarity, adaptive evaluation and optimization of the quality of question and answer generation is achieved. Compared with the solution of using a fixed similarity threshold, this embodiment can dynamically adjust the evaluation criteria according to the changes in multi-dimensional indicators such as semantic expression, length characteristics, and context density between the candidate answers and the quoted content, so as to more accurately distinguish the quality of semantic matching. In addition, by introducing a feedback optimization mechanism, the generation parameters and citation strategies are automatically adjusted when the similarity does not meet the standards, which effectively improves the semantic consistency and content alignment between the generated results and the original quoted content. It significantly enhances the adaptability of the question and answer system to semantic drift, redundant citations or expression deviations in complex contexts.
[0088] It should be noted that the fifth embodiment of the present application may also be an improvement based on any one or more of the first to fourth embodiments.
[0089] The step division of the above various methods is only for the purpose of clear description. During implementation, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this application; adding insignificant modifications or introducing insignificant designs to the algorithm or process without changing the core design of the algorithm and process are all within the scope of protection of this application.
[0090] In addition, some embodiments of the present application further provide an electronic device. The electronic device may be various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, etc. The electronic device may also be various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices.
[0091] The electronic device includes: one or more processors; and a memory storing computer program instructions, and when the computer program instructions are executed, the processor executes a question and answer generation method based on reference verification and similarity constraints as provided in any one or more of the above embodiments. Figure 2 An exemplary structural diagram of the electronic device is disclosed. The electronic device includes: one or more processors 1101, a memory 1102, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses and can be installed on a common motherboard or installed in other ways as needed. The processor can process instructions executed within the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to the interface). In some other embodiments, if necessary, multiple processors and / or multiple buses can be used with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, with each device providing some of the necessary operations. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0092] The electronic device may further include: an input device 1103 and an output device 1104. The processor 1101, the memory 1102, the input device 1103 and the output device 1104 may be connected via a bus or other means. Figure 2 The bus connection is taken as an example.
[0093] Input device 1103 can receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. Examples include a touch screen, keypad, mouse, trackpad, touchpad, pointing stick, one or more mouse buttons, trackball, joystick, and other input devices. Output device 1104 may include a display device, auxiliary lighting devices (e.g., LEDs), and tactile feedback devices (e.g., vibration motors). The display device may include, but is not limited to, a liquid crystal display, a light emitting diode display, and a plasma display. In some embodiments, the display device may be a touch screen.
[0094] To provide user interaction, the electronic device may be a computer. The computer includes a display device (e.g., a cathode ray tube or LCD monitor) for displaying information to the user, and a keyboard and pointing device (e.g., a mouse) through which the user can provide input to the computer. Other types of devices may also be used to provide user interaction; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback), and input from the user may be received in any form (e.g., voice input or tactile input).
[0095] In an embodiment of the present application, a computer program / instruction is stored on a computer-readable medium. When the computer program / instruction is executed by a processor, the method for generating a question and answer based on reference verification and similarity constraints provided in any one or more of the above embodiments is implemented. The computer-readable medium may be included in the electronic device described in the above embodiments; or it may exist independently without being incorporated into the device. The computer-readable medium carries one or more computer-readable instructions.
[0096] The memory 1102 can be used as a non-transitory computer-readable storage medium to store non-transitory software programs, non-transitory computer executable programs, and modules. The processor 1101 executes the non-transitory software programs, instructions, and modules stored in the memory 1102 to execute various functional applications and data processing of the server, thereby implementing the program instructions / modules corresponding to the method provided in any one or more of the above embodiments of the present application.
[0097] The memory 1102 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device, etc. In addition, the memory 1102 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 1102 may optionally include a memory remotely located relative to the processor 1101, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0098] It should be noted that the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above. Computer-readable media may be, for example, but not limited to: electrical, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or components, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical fiber, a portable compact disk read-only memory, an optical storage device, a magnetic storage device, or any suitable combination of the above. In this application, a computer-readable medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or device.
[0099] Computer-readable media includes both permanent and non-permanent, removable and non-removable media, and can be implemented using any method or technology for information storage. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory, static random access memory, dynamic random access memory, other types of random access memory, read-only memory, electrically erasable programmable read-only memory, flash memory or other memory technology, compact discs, digital versatile discs or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
[0100] Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as C or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network or a wide area network, or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0101] In the above embodiments, all or part of the steps or functions of the present invention may be implemented using software, hardware, firmware, or any combination thereof. For example, implementation may be achieved using a dedicated integrated circuit, a general-purpose computer, or any other similar hardware device. In some embodiments, the software program of the present application may be executed by a processor to implement the above steps or functions. Similarly, the software program of the present application (including related data structures) may be stored in a computer-readable recording medium, such as a RAM memory, a magnetic or optical drive, a floppy disk, or the like. In addition, some steps or functions of the present application may be implemented using hardware, for example, as a circuit that cooperates with a processor to perform the various steps or functions.
[0102] The computer program product provided in the embodiments of the present application includes one or more computer programs / instructions that, when executed by a processor, fully or partially produce the processes or functions described in accordance with the embodiments of the present application. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive).
[0103] The flowcharts or block diagrams in the accompanying drawings illustrate the possible architectures, functions and operations of the devices, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, program segment or part of code, and the module, program segment or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, as well as the combination of boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-specific system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0104] The scope of this application is defined by the appended claims rather than the foregoing description and is therefore intended to encompass within this application all changes that come within the meaning and range of equivalents of the claims. Any reference signs in the claims should not be construed as limiting the claims to which they relate. In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in a device claim may also be implemented by one unit or device through software or hardware. Words such as "first" and "second" are used only to distinguish the description and do not indicate any particular order, nor should they be understood as indicating or implying relative importance.
[0105] The above descriptions are merely specific embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art may easily propose variations or substitutions within the technical scope disclosed in the present application, and such variations or substitutions shall be encompassed within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the scope of protection of the claims, and the above descriptions shall be regarded as exemplary and non-limiting. < / h1>
Claims
1. A question-answer generation method based on reference verification and similarity constraint, characterized in that: include: Get the document content related to the question entered by the user; Based on the document content, a reference list is generated using a generation model, wherein the reference list includes one or more reference contents, each of which is composed of an original text segment extracted from the document content, and rewriting of the original text segment is not allowed during the generation process; Perform consistency verification on each reference in the reference list and the corresponding original text segment in the document content. If any reference fails the verification, the reference list is regenerated until all references in the reference list pass the consistency verification. On the basis that the reference list passes the consistency verification, generating candidate answers based on the question input by the user, calculating the semantic similarity between the candidate answers and the reference list, and obtaining a similarity score value; Comparing the similarity score with a preset similarity threshold; if the similarity score is lower than the similarity threshold, re-performing the reference list generation and consistency verification process, as well as the candidate answer generation process, until the reference list passes the consistency verification and the similarity score meets the similarity threshold requirement; Output candidate answers that meet the reference consistency verification and similarity requirements, and together with the question entered by the user, form a question-answer pair.
2. The question-answer generation method based on reference verification and similarity constraint according to claim 1 is characterized in that: Before the step of generating a reference list based on the document content using a generation model, the method further includes: performing structural preprocessing on the document content, wherein the structural preprocessing includes: Divide the document content into paragraphs, sentences, or logical levels, extract the text content of each content unit based on the document layout information and semantic tags, and attach location information to each content unit. The attached location information includes the page number, paragraph number, or line number, as well as the starting character offset position in the document. Generate a unique identifier for each content unit, calculate a corresponding text hash digest value, and establish a mapping index structure of the unique identifier, the text hash digest value, and the original text content; A document structure tree is constructed to record the hierarchical relationship and logical context path between each content unit. The document structure tree includes chapter title path, parent-child structure identifier and logical sequence information.
3. The question-answer generation method based on reference verification and similarity constraint according to claim 2 is characterized in that: The step of generating a reference list based on the document content using a generation model includes: In a prompt instruction input to a generation model for generating a reference list, a mandatory reference prompt template including a format control mark is set, wherein the mandatory reference prompt template is used to require that a reference list must be generated first in an output result; The generation model filters original text segments that are semantically relevant to the question from the structured document content based on the question input by the user, and outputs one or more reference contents that are content-formatted and annotated with location information according to the mandatory reference prompt template to generate the reference list. The original text segments include one or more content units, or a continuous text segment within at least one content unit.
4. The question-answer generation method based on reference verification and similarity constraint according to claim 1 is characterized in that: The step of performing consistency verification on each reference content in the reference list and the corresponding original text segment in the document content, and triggering regeneration of the reference list if any reference content fails the verification, until all reference contents in the reference list pass the consistency verification, includes: For each reference content in the reference list, locate the corresponding original text segment in the document content based on the position information carried; Based on the original text segment and the quoted content, dynamically select literal comparison or hash comparison to perform consistency check to determine whether the quoted content has been tampered with, added, deleted, or rewritten at the text level; When any reference content in the reference list fails the consistency check, the reference list generation process is triggered to be re-executed, and a prompt instruction for generating the reference list is resent to the generation model; The prompt instruction dynamically adjusts the format control requirements, reference strategy parameters or generation constraint rules according to the type, location and error characteristics of the previous round of reference verification failure, thereby guiding the generation model to output a new reference list until all reference contents in the reference list pass the consistency verification.
5. The question-answer generation method based on reference verification and similarity constraint according to claim 1 is characterized in that: The step of generating candidate answers based on the question input by the user on the basis that the reference list passes the consistency verification, calculating the semantic similarity between the candidate answers and the reference list, and obtaining a similarity score value includes: Inputting the reference content in the reference list and the candidate answer into a pre-trained semantic encoding model to generate respective semantic vectors; Calculating a semantic similarity score between the candidate answer and each quoted content based on the cosine similarity between the semantic vector of the candidate answer and the semantic vector of each quoted content; The semantic similarity scores are merged according to a preset weighting strategy to calculate the overall semantic similarity score between the candidate answer and the reference list. The weighting strategy includes determining the weight coefficient of each reference content based on at least one indicator of the position information of the reference content in the original text, the text length, and the text density.
6. The question-answer generation method based on reference verification and similarity constraint according to claim 1 is characterized in that: The step of comparing the similarity score with a preset similarity threshold and, if the similarity score is lower than the similarity threshold, re-executing the reference list generation and consistency verification process, as well as the candidate answer generation process, until the reference list passes the consistency verification and the similarity score meets the similarity threshold requirement, includes: Based on the text length, semantic compression rate, number of citations in the reference list, semantic density, semantic complexity, semantic dispersion, and context closeness of the candidate answers, a similarity threshold adjustment function is constructed. Dynamically adjust the preset basic threshold interval using the adjustment function to output the currently applicable semantic similarity threshold; The similarity score value is compared with the currently generated semantic similarity threshold. If the similarity score value is lower than the semantic similarity threshold, it is determined that the semantic relevance of the current question and answer result is insufficient, triggering the re-execution of the entire process of reference list generation, reference consistency verification and candidate answer generation.
7. The question-answer generation method based on reference verification and similarity constraint according to claim 6, characterized in that: The adjustment mechanism of the adjustment function includes: feedback optimization based on the failure information of the previous round of semantic similarity score not meeting the semantic similarity threshold, dynamically adjusting the generation constraint parameters, the screening range of the reference content and the semantic concentration ratio in the candidate answer generation process, so as to enhance the semantic convergence and similarity compliance between the candidate answers and the reference content in the question and answer generation process.
8. An electronic device, characterized in that: The electronic device comprises: One or more processors; and a memory storing computer program instructions, wherein when the computer program instructions are executed, the processor executes the question-answer generation method based on reference verification and similarity constraint according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program and / or instructions stored thereon, characterized in that: When the computer program and / or instructions are executed by a processor, the question-answer generation method based on reference verification and similarity constraints as described in any one of claims 1 to 7 is implemented.
10. A computer program product comprising a computer program and / or instructions, characterized in that When the computer program and / or instructions are executed by a processor, the question-answer generation method based on reference verification and similarity constraints as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Large language model question and answer optimization method and device, electronic equipment and storage medium
CN117851575A
Document question-answering system and method based on large model
CN119577087A
Document consistency comparison method based on semantic analysis and keyword driving
CN119886103A
Text generation method and device, electronic equipment and readable storage medium
CN120336499A
Large Language Model System
JP7691792B1
Cited By
Question and answer pair generation method and system, computer equipment and readable storage medium
CN121434347A
Progressive document generation method and device with theme and template double constraints
CN122221826A
A method and apparatus for progressive generation of a document with dual constraints of theme and template
CN122221826B