Question and answer generation method, device, medium and program product based on reference verification and similarity constraint
By employing citation verification and similarity constraint mechanisms, the problems of inconsistent citations and content distortion in question-and-answer generation are resolved, ensuring the credibility and semantic relevance of the generated answers. This approach is suitable for highly reliable applications such as legal interpretation, enterprise knowledge Q&A, and intelligent customer service.
Patent Information
- Application Number
- CN202511115058.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-11
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-08-11
AI Technical Summary
Existing technologies suffer from inconsistent citations and distorted content generation during the question-and-answer generation process, which can easily lead to illusory errors or semantic disconnects in the question-and-answer results, making it difficult to meet the requirements of highly reliable, auditable, and traceable enterprise-level applications.
By introducing citation verification and similarity constraint mechanisms, the consistency between the generated citation content and the original text is ensured. The semantic similarity scoring controls the answer generation process, including literal and hash-level consistency verification, and a dynamic iterative generation mechanism to meet preset standards.
It significantly improves the credibility and semantic relevance of question-and-answer results, ensuring that the answers are credible and semantically relevant, making it suitable for highly reliable application scenarios such as legal interpretation, enterprise knowledge Q&A, and intelligent customer service.
Smart Images

Figure CN120611032B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular relates to a question and answer generation method and device based on reference verification and similarity constraint, a medium and a program product. BACKGROUND
[0002] With the wide application of large language models (LLM) in document question and answer systems, the retrieval augmented generation (RAG) architecture has become the mainstream solution in the industry. Such a solution usually retrieves the original document before generating an answer, extracts relevant document paragraphs from the user question, and uses them as the input context of the large language model, thereby narrowing the model's reasoning space and reducing the probability of answer errors to some extent.
[0003] However, the RAG solution still has the following problems in practical application:
[0004] Reference uncertainty problem: Although the model claims that its output content comes from the retrieved document segment, there is a lack of strong constraints on the one-to-one correspondence between the reference content and the original document, which easily leads to phenomena such as reference rewriting, splicing, and even fabrication, resulting in a lack of verifiability of the generated results.
[0005] Insufficient answer relevance problem: the relevance between the generated answer and the reference content cannot be guaranteed. Even if the model correctly references the document content, the generated answer may still have semantic jumps or logical distortions, which cannot ensure that it is highly consistent with the reference content, thereby causing factual bias or "hallucination" problems.
[0006] Therefore, the prior art does not establish an end-to-end quality control mechanism from reference generation to answer output, and the current document-based question and answer system still cannot meet the high-trust, auditable, and traceable enterprise-level application requirements. SUMMARY
[0007] In view of the deficiencies of the prior art, the present application provides a question and answer generation method and device based on reference verification and similarity constraint, a medium and a program product, at least to solve the problem that the existing question and answer generation process has inconsistent references and distorted content generation, resulting in hallucination errors or semantic disconnection in the generated question and answer results.
[0008] To achieve the above-mentioned purposes and other advantages, some embodiments of the present application provide the following aspects:
[0009] In a first aspect, some embodiments of the present application provide a question and answer generation method based on reference verification and similarity constraint, comprising:
[0010] obtaining document content related to the user input question;
[0011] generating, based on the document content, a reference list using a generative model, the reference list comprising one or more reference contents, each of the reference contents being constituted by an original text segment extracted from the document content, and the original text segment being not allowed to be revised in the generation process;
[0012] performing consistency verification on each of the reference contents in the reference list and the corresponding original text segment in the document content, and if any of the reference contents fails the verification, triggering re-generation of the reference list until all of the reference contents in the reference list pass the consistency verification;
[0013] generating, based on the user input question, a candidate answer on the basis that the reference list passes the consistency verification, calculating semantic similarity between the candidate answer and the reference list, and obtaining a similarity score value;
[0014] comparing the similarity score value with a preset similarity threshold value, and if the similarity score value is lower than the similarity threshold value, re-executing the generation and consistency verification process of the reference list and the generation process of the candidate answer until the reference list passes the consistency verification and the similarity score value meets the similarity threshold requirement;
[0015] outputting the candidate answer that meets the reference consistency verification and the similarity requirement, and constituting a question and answer pair together with the user input question.
[0016] In a second aspect, some embodiments of the present application further provide an electronic device, comprising:
[0017] one or more processors; and a memory storing computer program instructions which, when executed, cause the processor to perform the question and answer generation method based on reference verification and similarity constraint as described in any of the above.
[0018] In a third aspect, some embodiments of the present application further provide a computer readable storage medium having stored thereon computer programs and / or instructions which, when executed by a processor, implement the question and answer generation method based on reference verification and similarity constraint as described in any of the above.
[0019] In a fourth aspect, some embodiments of the present application further provide a computer program product comprising computer programs and / or instructions which, when executed by a processor, implement the question and answer generation method based on reference verification and similarity constraint as described in any of the above.
[0020] Compared with the related art, in the scheme provided by the embodiment of the application, after generating the model output reference content, the system verifies the literal level or hash level consistency of each reference with the document original text, ensures that the reference source is not rewritten or misused, avoids "illusion" content flowing into the question and answer result, and enhances the credibility basis of the question and answer. After generating the candidate answer, the semantic similarity is calculated to measure whether the answer content is in sufficient semantic fit with the reference content, effectively suppressing the output of irrelevant or weakly related answers. Therefore, by introducing the reference consistency verification mechanism and the semantic similarity score constraint mechanism, the traceability, accuracy and semantic relevance of the answer content are significantly improved in the process of generating the question and answer result. In addition, the dynamic iteration generation mechanism of the scheme of the application automatically retries and adjusts the generation strategy in the case of unsatisfactory reference or semantics, ensures that the final output question and answer pair meets the preset standards in the two dimensions of source credibility and semantic accuracy, and is especially suitable for high-reliability question and answer application scenarios such as regulation interpretation, enterprise knowledge question and answer, intelligent customer service and knowledge management. BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the application, the drawings needed to be used in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor.
[0022] Figure 1 is a flow diagram of a question and answer generation method based on reference verification and similarity constraint provided by the embodiment of the application;
[0023] Figure 2 is a structural schematic diagram of an electronic device provided by the embodiment of the application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical scheme and advantages of the embodiments of the application more clear, the technical solutions in the embodiments of the application will be described clearly and completely with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are some embodiments of the application, not all embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the application.
[0025] First embodiment
[0026] The first embodiment of the application relates to a question and answer generation method based on reference verification and similarity constraint, referring to Figure 1 The method can include the following steps:
[0027] Step S1: Obtain document content related to the user input question.
[0028] For step S1, specifically, the user input question can include, but is not limited to, factual questions, explanatory questions, program operation questions, data extraction questions, judgment reasoning questions, etc. in the form of natural language. The document content can include structured / semi-structured policy files, business documents in natural language format, knowledge base materials, enterprise internal documents, and any uploaded user-defined text, etc.
[0029] The natural language question input by the user is received, and language preprocessing operations are performed on the question, including but not limited to word segmentation, keyword extraction, semantic analysis, and question type recognition, etc. to obtain the core intention and key expression of the question. Then, based on the extracted semantic features, the target document set with semantic relevance to the question is screened out in the preset document library. The document set can include one or more documents. For example, for the user input question "What is the return and exchange process of the product?", the system can retrieve the "return and exchange instructions" related chapter from the product user agreement, help center document, etc. and further divide the chapter into multiple content units containing location information and text hash values as the content source for subsequent reference generation and verification.
[0030] It should be noted that in actual application, the method of the present embodiment not only supports processing a single natural language question, but also supports parallel processing or dialogue context modeling of multiple natural language questions (for example, batch processing or multi-round dialogue), by performing reference generation and verification processes for each question respectively, to ensure the reliability and traceability of the generated question and answer pairs. It is suitable for scenarios of batch generating high-quality question and answer pairs in question and answer robots or document intelligent analysis systems.
[0031] Step S2: Based on the document content, a reference list is generated using a generation model, the reference list including one or more reference contents, each reference content being composed of an original text segment extracted from the document content, and the original text segment not being allowed to be rewritten in the generation process.
[0032] 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 can include: reference content (original text segments directly extracted from the document, which cannot be modified by the model), location information (including page number, section number, character starting offset position, etc.), unique identifier, optional hash check code, format label (such as markdown reference symbol, structured JSON label). The generation model can be a large language model fine-tuned by instructions, which can generate structured text content according to the input natural language instructions, such as GPT-type models, T5-type models or other language models supporting question and answer generation and content extraction functions. It can also use multi-modal generation models such as GPT-4V, BLIP, MiniGPT, which have the ability to mix text and images, and support input documents containing images or tables and other non-text content. The reference content must be the original sentence or segment directly extracted from the document, and the model is not allowed to process, generate or modify it to ensure its authenticity and traceability.
[0033] Step S3: consistency verification is performed 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 is regenerated until all reference contents in the reference list pass the consistency verification.
[0034] For step S3, specifically, for each reference content in the reference list, its attached location information (including page number, section number, character offset, etc.) is extracted to accurately locate the corresponding original text segment in the document content. Consistency verification is performed based on the located original text segment and the reference content, including literal comparison and hash comparison. Literal comparison refers to directly comparing whether the string content of the reference content and the original text segment is completely consistent. Hash comparison calculates the hash digest value of the reference content and the original text segment respectively using a text hash algorithm such as SHA-256, and judges whether they are consistent. If there is any inconsistency between any reference content and the original text segment (such as text being rewritten, truncated or concatenated), it is determined that the current reference list fails the consistency verification, triggering the re-execution of the reference generation process. When regenerating the reference list, feedback signals can be constructed based on the content characteristics of the current failed reference, error types (such as location offset, concatenation error, digest inconsistency), etc. to dynamically optimize the prompt instructions of the next round of generation model, appropriately adjust the generation constraints, reference style or content extraction range, thereby improving the consistency and verifiability of the reference generation results. This process continues iteratively until all reference contents in the generated reference list pass the consistency verification, ensuring that all reference contents are real, complete and unmodified original text segments, effectively supporting the traceability verification and accuracy guarantee of subsequent question and answer content.
[0035] Step S4: On the basis that the citation list passes the consistency verification, a candidate answer is generated based on the question input by the user, the semantic similarity between the candidate answer and the citation list is calculated, and a similarity score value is obtained.
[0036] For step S4, specifically, based on the question input by the user, a natural language answer is generated by calling a language generation model under the preset generation instruction prompt. The instruction prompt can include the context type of the question, the answer style limitation, the output format constraint, etc., to guide the model to generate a candidate answer that meets the semantic requirements according to the established strategy. The generation process of the candidate answer can reuse the same large language model (LLM) or lightweight instruction fine-tuning model as the citation list generation, that is, in the same model system, the citation generation and answer generation tasks are completed uniformly. In this way, the resource overhead caused by frequently switching models or calling different interfaces between citation generation and answer generation is avoided, and the overall processing efficiency is improved.
[0037] After the candidate answer is generated, the citation content of the citation list is used as the reference content for semantic verification, and the semantic vector model (such as the SBERT model) is used to match the candidate answer, to calculate the overall semantic similarity score, so as to evaluate whether the answer content is highly consistent with the document, thereby controlling the reliability of the output facts. For example, after the system generates the answer "the user can apply for return and exchange within 7 days", the answer is compared with multiple original text segments in the citation list for semantic comparison, and a similarity score value of 0.91 is obtained. If the similarity threshold requirement is met, the output is the final question and answer result.
[0038] Step S5: Compare the similarity score value with the preset similarity threshold value. If the similarity score value is lower than the similarity threshold value, the generation and consistency verification process of the citation list and the generation process of the candidate answer are re-executed until the citation list passes the consistency verification and the similarity score value meets the similarity threshold requirement.
[0039] For step S5, specifically, the similarity score value 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 similarity threshold is set to 0.85, if the similarity score value is lower than the similarity threshold, it is considered that the candidate answer fails to adequately reflect the core semantic information expressed by the reference content, and needs to be regenerated. When the similarity score value does not meet the dynamically calculated threshold, the system will trigger the regeneration and consistency verification process of the reference list, and the regeneration process of the candidate answer. At the same time, the reasons for the failure of the previous round of comparison (such as long answer, semantic expression deviation, 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, to improve the semantic convergence and compliance rate of the subsequent question and answer generation process, reduce the misjudgment probability caused by language style differences, and thus improve the stability and effectiveness of the overall generation result.
[0040] Step S6: output the candidate answer that meets the reference consistency verification and similarity requirements, and jointly constitute a question and answer pair with the user input question.
[0041] 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 original user input question to form a final question and answer pair, and assign a unique identification number to support subsequent calling and management. The question and answer pair can be packaged into a standardized output format, including but not limited to JSON format, Markdown format, or a preset question and answer platform custom data structure, to support visual display and programmatic access in search engine interfaces, intelligent question and answer platforms, document intelligent assistants, and other application scenarios. The system can attach the position information, similarity score value and verification state field of the reference list to the question and answer output to support subsequent auditing, debugging or multi-round interactive retrieval process, and improve the traceability and explainability of the question and answer result.
[0042] Compared with the related art, in the scheme provided by the embodiments of the present application, after generating the model output reference content, the system verifies the literal level or hash level consistency of each reference with the document original text, ensures that the reference source is not rewritten or misused, avoids "illusion" content flowing into the question and answer result, and enhances the reliable basis of the question and answer. After generating the candidate answer, the semantic similarity is calculated to measure whether the answer content is semantically consistent with the reference content, effectively suppressing the output of irrelevant or weakly related answers. Therefore, by introducing the reference consistency verification mechanism and the semantic similarity scoring constraint mechanism, the traceability, accuracy and semantic relevance of the answer content are significantly improved in the process of generating the question and answer result. In addition, the dynamic iteration generation mechanism of the present application automatically retries and adjusts the generation strategy in the case of unsatisfactory reference or semantics, ensures that the final output question and answer pair meets the preset standards in the dimensions of source credibility and semantic accuracy, and is especially suitable for high-reliability question and answer application scenarios such as regulation interpretation, enterprise knowledge question and answer, intelligent customer service and knowledge management.
[0043] Second embodiment
[0044] The second embodiment of the present application relates to a question and answer generation method based on reference verification and similarity constraint. The second embodiment is an improvement based on the first embodiment, and the specific improvement is that in the second embodiment of the present application, a document structured preprocessing mechanism is introduced, that is, the document content is structured and preprocessed before step S2 is performed, specifically including:
[0045] Step A1: dividing the document content according to paragraphs, sentences or logical levels, extracting the text content of each content unit based on the document layout information and semantic markers, and adding position information to each content unit. The added position information includes page number, paragraph number or line number, and starting character offset position in the document.
[0046] Specifically, the system first performs a content division operation on the input document content. The division method can include paragraph division, sentence division or logical level division. Paragraph division: according to the natural paragraph boundary in the document, such as paragraph markers or paragraph indentation symbols. Sentence division: further divide each paragraph of text into sentence-level units by means of sentence division rules or natural language processing models (such as dependency syntax analysis, BERT sentence division model). Logical level division: identify chapters, sections, subsections and other logical units according to the document directory index structure and title number style.
[0047] After the content division is completed, the system further combines the document's layout structure information (e.g. PDF page number, Word style, HTML tag) and semantic marking information (e.g. paragraph start recognized by natural language model or title semantics) to extract the pure text content of each content unit. For example, for a PDF format document, the page number, font style, paragraph layout, etc. information in its metadata can be parsed; for an Office document (such as Word), its paragraph style, title tag, etc. structure markers can be used; for an HTML format web page, the tags (such as <h1>、 、 Positioning content boundaries.
[0048] While extracting each content unit, the system attaches position information to the unit, which can include page number (identifying the page number of the document where the content unit is located), section or line number (paragraph number or text line sequence 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), binding the attached position information with the original text to form a structured content unit, which is used for accurate mapping of subsequent reference consistency verification, ensuring that the reference text can be effectively positioned and checked.
[0049] Step A2: Generate a unique identifier for each content unit and calculate the corresponding text hash digest value, and establish a mapping index structure of unique identifier, text hash digest value and original text content.
[0050] For each content unit divided in step A1, a unique identifier corresponding to it is further generated to realize the unique positioning and reference tracking of the content unit. The unique identifier can be generated in one of the following ways: using the position information of the content in the document to encode, using the hierarchical number of the content in the document structure, or directly generating a globally unique identifier for each content unit.
[0051] After generating the identifier, the system also performs hash calculation operation on the text of each content unit. Specifically, a hash algorithm such as SHA-256, MD5, etc. is used to generate a digest of the text, forming a strict hash value corresponding to the content. The hash digest can be used for subsequent verification of whether the generated reference is consistent with the original text content. If the document content is modified, only the hash values need to be compared to quickly locate the differences. The generated unique identifier, text hash digest value and the original text content of the unit are mapped to establish a ternary mapping index structure. The mapping structure can be organized by key-value storage (such as hash table or key-value database). In the question and answer generation task, when the model outputs a certain reference content, the system can find the corresponding original text through its identifier and verify its consistency based on the hash digest, thereby realizing the mechanism of unalterable reference.
[0052] Step A3: Build a document structure tree to record the hierarchical relationship and logical context path between content units. The document structure tree includes chapter title path, parent-child structure identification and logical sequence information.
[0053] Specifically, after completing the content unit division and identifier and digest index construction, the system further models the structural hierarchy of the document to form a document structure tree, which is used to fully represent the organizational relationship and context path between various content units, thereby providing structured support for reference selection, context reasoning and structured retrieval.
[0054] A document structure tree refers to organizing content units of a document into a directed tree (or a multi-way tree) structure, wherein each node represents a content unit; edges represent hierarchical or subordinate relationships, for example, a paragraph belongs to a chapter, and a subsection is a child node of a section; the root node of the tree is the logical starting point of the entire document (such as the title page or overview), and the leaf node of the tree corresponds to a basic content unit that cannot be further divided (such as a single sentence or a text segment). For each structure tree node, record its structure attribute information, such as chapter title path, parent-child structure identifier, and logical order information. The document structure tree can be automatically extracted based on the directory information and title level of the document, or the subordinate relationship between paragraphs can be determined with the aid of a natural language processing model. For texts without explicit directories (such as PDF or OCR scanned documents), the structure can be inferred and constructed by combining font size, indentation, numbering patterns, and other formatting features.
[0055] By constructing a document structure tree, in the reference extraction stage, the context where the reference content is located can be located based on the chapter path and logical order; in the answer generation, the context path provided by the document structure tree can be used as a location prompt to assist the model in generating answers with more logical coherence; in the reference verification, the reference reliability and context consistency can be improved through parent node comparison or cross-verification of nodes at the same level; and for batch generation of multiple questions and answer pairs, the relevant paragraphs can be located and clustered in batches through the document structure tree, thereby improving the generation efficiency.
[0056] By introducing a document structuring 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 reference generation module can accurately associate the original text segment when outputting the reference content; in the subsequent consistency verification stage, by comparing the hash digest or location marker, it can quickly determine whether the reference content has been rewritten, truncated, or spliced, significantly improving the accuracy and traceability of the reference. On the other hand, with the help of the document structure tree, the hierarchical relationships and context paths between content units are modeled, and in the reference generation stage, the model can be assisted by chapter context, parent-child structure, and other prompt information to filter reference segments with more coherent context and complete semantics, thereby enhancing the semantic consistency and context adaptability of the reference content and avoiding semantic deviations caused by selective quoting.
[0057] The index structure and hierarchical relationships established by the structured preprocessing also support fast positioning and batch aggregation of reference content. In multi-round question and answer, batch generation, or intelligent summary scenarios, multiple relevant references can be efficiently extracted according to the problem semantics, significantly improving the overall efficiency of the question and answer generation system and the automation ability of reference calling.
[0058] Further, after the structured preprocessing of the document content, the embodiment also provides a specific implementation of generating a reference list based on a mandatory reference prompt template, that is, step S2 can further include the following steps:
[0059] Step S201: In the input prompt instruction for generating a reference list to the generation model, a mandatory reference prompt template containing a format control mark is set, and the mandatory reference prompt template is used to require that the reference list must be generated in the output result.
[0060] Specifically, before calling the generation model to generate the reference list, a prompt instruction is constructed and injected, which embeds a mandatory reference format template for specifying the content format of the model output and explicitly requiring the priority output of the reference content list. The template has the following characteristic elements:
[0061] Format control mark: used to guide the generation model to use a pre-defined structure mark to explicitly mark the reference content in the output result. For example, the format of "[reference start]...[reference end]", JSON object block, Markdown reference block, etc. can be used to clearly demarcate the start and end boundaries of each reference content.
[0062] Position information requirement: each reference content must be accompanied by structured position information fields in the source document, such as page number, paragraph number or line number, character start offset, unique identifier, etc.
[0063] Content source constraint: the template explicitly requires that the reference content must be strictly quoted from the original text content in the structured document, and does not allow any rewriting, abbreviation, splicing or reconstruction based on model understanding.
[0064] Quantity range and style limit: according to the specific application scenario, the number range of reference generation, the maximum text length of each reference, and whether the reference can cross multiple logical units or sentences, etc. can be set by the template.
[0065] The template reduces the risk of mismatch or rewriting when the model freely generates references through hard format control and explicit reference requirements.
[0066] Step S202: The generation model filters the original text fragments related to the semantic of the question from the structured document content according to the user input question, and outputs one or more reference contents formatted by content and annotated by position information according to the mandatory reference prompt template to generate a reference list, the original text fragments include one or more content units, or continuous text fragments within at least one content unit.
[0067] Specifically, after receiving the prompt instruction, the generation model performs semantic comparison between the user input question and each content unit in the structured document content, and selects content units or internal fragments closely related to the question semantics from the content units by means of built-in attention mechanism, embedding vector similarity, etc.
[0068] For the selected original text fragment, the model performs formatting processing according to the prompt template requirements, such as retaining the original text, prohibiting any rewriting or truncation, adding source location markers such as page numbers, section numbers, and character offsets, and if the extracted is a continuous fragment inside a content unit, retaining the unit number and recording the offset range. The formatted reference content is output in a list structure as a reference list corresponding to the current question.
[0069] Each reference content in the reference list can be: a complete content unit, a continuous sentence in a content unit, or a logical fragment formed by splicing multiple content units.
[0070] By driving the reference list generation based on the mandatory reference prompt template, the output structure of the generation model is explicitly specified, so that the reference content has clear start and end boundaries and structured properties in form. The meta-information such as page number, section number, and character offset can directly correspond to the document index structure constructed in the preprocessing stage, realizing fast backtracking of the original text and avoiding model misquotation or reference out of context. Moreover, the template limits the reference content to be a strict excerpt of the document original text, and strictly prohibits rewriting, splicing, or language reconstruction, which eliminates the semantic drift, factual errors, or difficult-to-verify problems caused by model free generation, significantly improving the authenticity and auditability of the reference. Especially in high-audit scenarios such as law, medicine, and finance, the traceability and verifiability of the answer source can be guaranteed. Therefore, combined with the structured document and semantic screening mechanism, the generation model can accurately extract the original text fragments strongly related to the question under the template constraint, improving the relevance and accuracy of the reference content.
[0071] Third embodiment
[0072] The third embodiment of the present application relates to a question and answer generation method based on reference verification and similarity constraint. The third embodiment is an improvement based on the first embodiment, and the specific improvement is that in the third embodiment of the present application, a specific implementation of dynamically verifying and driving the optimization generation of the reference list is provided, that is, step S3 can further include the following steps:
[0073] Step S301: For each reference content in the reference list, locate the corresponding original text fragment in the document content based on the carried location information;
[0074] Step S302: Based on the original text fragment and the quoted content, dynamically select literal comparison or hash comparison method to perform consistency verification in order to determine whether there is any text-level tampering, addition, deletion or rewriting behavior in the quoted content;
[0075] Step S303: If any reference in the reference list fails the consistency check, the reference list generation process is re-executed, and the prompt instruction for generating the reference list is resent to the generation model.
[0076] Step S304: The prompt instruction dynamically adjusts the format control requirements, reference strategy parameters, or generation constraint rules based on 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 references in the reference list pass the consistency verification.
[0077] Specifically, each referenced content is accompanied by location information fields generated by the structured preprocessing mechanism during the generation process, such as page number, paragraph number or line number, character start offset, and unique identifier. The system uses this location information as an index key to quickly locate its corresponding content unit from the index structure built from the structured document content.
[0078] If the referenced content covers a complete content unit, the system can directly use the original text of that content unit as the comparison source. If the referenced content involves consecutive segments (such as partial sentences) within a content unit, the system combines the start offset information to accurately extract the corresponding substring content from the original text. If the referenced content involves a logical segment formed by concatenating multiple content units, the system sequentially retrieves the original text of each content unit based on the multiple unique identifiers contained in the position information, and concatenates them in document order to form a comparison segment. If adjacent content units being concatenated contain character offset information or clause-level offset markers, sub-content pruning is performed on the first and last contents to accurately extract the original text segment corresponding to the referenced content.
[0079] After locating the cited content and the original text fragment, the system performs a consistency check on both to identify whether the citation has been tampered with, rewritten, or formatted. Specifically, this includes:
[0080] Literal comparison: The system employs a character-by-character comparison strategy to determine whether the original string and the quoted text are completely identical, including punctuation, spaces, capitalization, etc. Applicable scenarios include: quoted content is a single sentence or a complete paragraph; the text format is standard, without line breaks or encoding disturbances; and the user or model outputs standard copied and pasted content.
[0081] Hash comparison: The system calculates encrypted hash values (such as SHA-256 and MD5) for both the original text and the cited content, and compares whether they match. This method is unaffected by formatting differences such as spaces and line breaks, and has higher fault tolerance. Applicable scenarios include: citations that are logical fragments formed by concatenating multiple content units; text containing line breaks, indentation, or encoding format disturbances; and character-level changes caused by unstructured export formats (such as PDF to HTML).
[0082] The system introduces an overall validity check for the citation list. The validity of the citation list is determined only if all cited content passes the consistency check. If any citation item fails the consistency check, the current citation list is considered to have a potential risk of content tampering, truncation, or mismatch, and is therefore deemed invalid. To ensure the verifiability and credibility of the final generated question-and-answer results, the system will immediately interrupt the current question-and-answer generation process and initiate the next round of automatic citation list regeneration. During this process, the system will resend the citation list generation prompt to the generation model and re-initiate the citation extraction request. At this time, the system records the specific information of the failed citation verification (including failure type, citation location, formatting error, text inconsistency, etc.).
[0083] Based on the specific information from the previous round of content verification failures, the prompt instructions are optimized and dynamically adjusted to improve the quality of the generated results and the verification pass rate in the new round. This dynamic adjustment includes the following strategies:
[0084] Format control requirements have been adjusted: the requirements for filling in boundary markers and position information fields in the reference template have been strengthened. For example, explicit prompts for [reference start] and [reference end] have been added, or mandatory validation rules for fields such as unique identifier number and character offset have been added.
[0085] Reference strategy parameter update: Adjust the scope of reference content extraction in the model, such as limiting the maximum length of a single reference, avoiding cross-segment references, and disabling fragment splicing, in order to avoid accidental content cutting and rewriting.
[0086] Strengthened generation constraints: Add soft and hard constraints such as "character-level exact match", "citations must include complete position 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.
[0087] The above adjustment strategy can be realized by means of programmatic template reconstruction, model prefix injection, prompt engineering reinforcement and the like, so as to ensure that the next round of model generation output is more standardized, compliant and verifiable. In order to ensure that all cited contents meet the consistency requirements, the system builds an automatic iteration mechanism, which performs consistency checking after each round of citation generation. If there are inconsistent citations, the prompt instruction parameters are dynamically adjusted and the citation contents are regenerated according to the error type. The iteration process continues to circulate until the verification is passed, so as to ensure that the citation contents are real, complete and traceable.
[0088] As can be seen, in the embodiments of the present application, the citation list optimization generation mechanism driven by dynamic verification is introduced, which realizes the consistency verification of each generated citation content, and automatically triggers the regeneration process when problems such as citation tampering, clipping or forgery are found. The mechanism supports dynamic adjustment of prompt instructions and generation constraint parameters according to the citation error type, and continues to iterate the generation and verification process until all citation contents pass the consistency verification. Thus, the generation of false citations can be effectively prevented, and the traceability, citation credibility and content accuracy of the question and answer system are significantly improved.
[0089] It should be noted that the third embodiment of the present application can also be an improvement on the basis of any one or more of the first embodiment to the second embodiment.
[0090] Fourth Embodiment
[0091] The fourth embodiment of the present application relates to a question and answer generation method based on citation verification and similarity constraint. The fourth embodiment is an improvement on the basis of the first embodiment, and the specific improvement is that in the fourth embodiment of the present application, a specific implementation of weighted fusion calculation of semantic similarity for evaluation is provided, that is, step S4 can further include the following steps:
[0092] Step S401: input the citation contents in the citation list and the candidate answer into a pre-trained semantic encoding model to generate respective semantic vectors;
[0093] Step S402: based on the cosine similarity between the semantic vector of the candidate answer and the semantic vector of each citation content, calculate the semantic similarity score of the candidate answer and each citation content respectively;
[0094] Step S403: fuse each semantic similarity score according to a preset weighting strategy to calculate the overall semantic similarity score value between the candidate answer and the citation list, and the weighting strategy includes at least one index based on the position information, text length and text density of the citation content in the original text to determine the weight coefficient of each citation content.
[0095] Specifically, the system inputs the candidate answer and each piece of reference content in the reference list into a pre-trained semantic encoding model (such as Sentence-BERT, RoBERTa, etc.) respectively to extract its corresponding semantic vector. The semantic vector is the expression of the original natural language in a high-dimensional space, which can capture deep semantic features and support fine similarity calculation. For each piece of reference content in the reference list , its semantic vector is generated , and the semantic vector of the candidate answer .
[0096] For the candidate answer and each piece of reference content, the cosine similarity is calculated respectively:
[0097]
[0098] wherein, denotes the semantic similarity score between the candidate answer and the th reference content, reflecting the closeness of their semantic expressions; denotes the dot product of two vectors, which is used to measure their similarity in direction; denotes the length of the semantic vector of the candidate answer and the th reference content semantic vector, respectively.
[0099] In order to comprehensively measure whether the candidate answer sufficiently covers all reference contents, the system weights and fuses each similarity score according to the importance of the reference content, and calculates the overall similarity score value :
[0100]
[0101] wherein, is the weighting coefficient of the th reference content, satisfying .
[0102] The weighting coefficient can be determined according to the following dimensions:
[0103] Reference position information: the reference content located in the key position of the core paragraph, abstract, conclusion, etc. in the original text has higher weight;
[0104] Text length index: the longer the reference content, the higher the information carrying capacity, and the corresponding weight can be improved;
[0105] Information density index: the reference content with higher keyword quantity, entity density or term coverage in unit length has greater weight;
[0106] Structural level factor: reference content from chapter title or high level structure paragraph can be given higher weight;
[0107] Artificial or heuristic rule: like prefer to promote the proportion of reference content highly related to problem semantics.
[0108] Through the above fusion strategy, the system realizes the global quantitative evaluation of the semantic matching degree between the candidate answer and the whole reference set, instead of relying on a single reference matching result.
[0109] As can be seen, in the embodiments of the present application, by introducing a similarity evaluation mechanism based on semantic vectors and combining a weighted fusion strategy, the semantic consistency between the candidate answer and the reference content is finely evaluated, which significantly improves the reliability and relevance of the reference-driven question and answer generation result. Compared with the scheme that only relies on text-level comparison, the present embodiment can effectively identify whether the candidate answer is truly semantically matched with the reference content, avoid the case of surface correlation or misusing the original text reference, enhance the consistency control of the question and answer system on semantic understanding and evidence support, and help to improve the credibility and review traceability of the final question and answer pair.
[0110] It should be noted that the fourth embodiment of the present application can also be an improvement on the basis of any one or more of the first to third embodiments.
[0111] Fifth embodiment
[0112] The fifth embodiment of the present application relates to a question and answer generation method based on reference verification and similarity constraint. The fifth embodiment is an improvement on the basis of the first embodiment, and the specific improvement is that in the fourth embodiment of the present application, a specific implementation of a similarity threshold dynamic adjustment mechanism driven question and answer quality control is provided, that is, step S5 can further include the following steps:
[0113] Step S501: based on the text length of the candidate answer, the semantic compression rate, the number of reference content in the reference list, the semantic density, the semantic complexity, the semantic dispersion and the context tightness of the reference content, a regulation function of the similarity threshold is constructed;
[0114] Step S502: dynamically adjust the preset basic threshold interval by using the regulation function, and output the currently applicable semantic similarity threshold;
[0115] 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 correlation of the current question and answer result is insufficient, and the whole process of generating the reference list, verifying the reference consistency and generating the candidate answer is triggered to be executed again.
[0116] Specifically, the system extracts several key feature variables as input factors before performing semantic similarity evaluation, including the text length of the candidate answer, semantic compression rate, the number of cited content in the citation list, semantic density, semantic complexity, semantic dispersion, and context tightness, etc. The text length can reflect the semantic carrying capacity of the answer; the semantic compression rate represents the degree of candidate answer compression of the original text information; the semantic density and complexity can evaluate the expression strength and understanding difficulty of the cited content; the semantic dispersion measures the semantic consistency between the cited fragments; and the context tightness reflects the structural adjacency degree of the cited content and the candidate answer in the original document. These feature variables constitute the input vector of the adjustment function after normalization processing.
[0117] The system inputs the above input factors into the threshold adjustment function to generate a dynamic threshold. The adjustment function can adopt a weighted linear model or a lightweight neural network structure to fuse the original basic threshold (such as 0.85) and the adjustment influence amount of each input factor, and output the currently applicable semantic similarity threshold. The threshold can dynamically change according to the context semantic conditions in each round of question and answer generation task, so as to more accurately evaluate the semantic quality of the candidate answer.
[0118] The system compares the similarity score value with the currently generated dynamic threshold. If the score value is lower than the threshold, it is judged that the semantic correlation of the current question and answer result is insufficient, triggering the re-execution of the citation list generation, citation consistency verification, and answer generation processes, and recording the failure information for continuous optimization of the adjustment strategy, realizing an adaptive question and answer generation control mechanism based on multi-factor input and feedback driving.
[0119] Further, the adjustment mechanism of the adjustment function includes: feedback optimization based on the failure information that the previous round of semantic similarity score does not meet the semantic similarity threshold, dynamically adjusting the generation constraint parameters, the screening range of cited content, and the semantic condensation ratio in the candidate answer generation process, to enhance the semantic convergence and similarity compliance ability between the candidate answer and the cited content in the question and answer generation process.
[0120] Specifically, when the semantic similarity score between the candidate answer and the cited content does not reach the currently set semantic similarity threshold, the system determines that this round of generation result fails, and extracts the failure information as feedback input, which includes but is not limited to: the position of the cited fragment that does not pass the threshold determination, the similarity score deviation amplitude, the semantic divergence features between the cited content and the answer, the context structure position of semantic drift, etc.
[0121] Under the driving of the feedback mechanism, the system automatically and dynamically adjusts multiple parameter paths in the question and answer generation process based on the above failure information. The adjustment strategy includes the following three aspects:
[0122] Generate constraint parameter adjustment: adjust the parameters of the candidate answer generation model, including output length limit, context coverage range, abstraction and refinement level, tone control (such as emphasis reference), etc., to make the generation result more focused on the core semantics expressed by the reference content.
[0123] Reference content filtering range optimization: adjust the content filtering strategy in the next round of reference list generation stage, such as increasing the weight priority of semantic similarity or structural proximity in reference filtering, narrowing down the candidate area or redefining the semantic search window, so as to select the reference content that is more consistent with the question and the answer.
[0124] Semantic concentration ratio control: dynamically control the summary level or retention granularity of the reference content, such as reducing the participation proportion of redundant sentences and improving the retention proportion of key sentences, so as to improve the semantic expression density and information alignment degree of the reference fragment as a whole.
[0125] Through the above feedback optimization mechanism, the adjustment function realizes the linkage optimization of generation control parameters and reference strategy, so as to enhance the semantic convergence between the candidate answer and the reference content, improve the ability of the next round of question and answer generation result to pass the semantic similarity check, and ensure that the final output result meets the quality standard set by the system in terms of content credibility and semantic consistency.
[0126] As can be seen, in the embodiments of the present application, by introducing the control mechanism based on dynamic threshold adjustment of semantic similarity, adaptive evaluation and optimization of the quality of question and answer generation are realized. Compared with the scheme using a fixed similarity threshold, this embodiment can dynamically adjust the judgment standard according to the changes of the candidate answer and the reference content in terms of semantic expression, length characteristics, context density and other multidimensional indicators, so as to more accurately distinguish the quality of semantic matching. In addition, by introducing the feedback optimization mechanism, the generation parameters and reference strategy are automatically adjusted when the similarity does not meet the standard, effectively improving the semantic consistency and content alignment degree between the generated result and the original reference content. The adaptability of the question and answer system to semantic drift, redundant reference or expression deviation in complex context is significantly enhanced.
[0127] It should be noted that the fifth embodiment of the present application can also be an improvement based on any one or more of the first to fourth embodiments.
[0128] The division of steps of the above methods is only for the purpose of clear description, and when implemented, one step can be combined or some steps can be split into multiple steps, as long as the same logical relationship is included, all within the protection scope of the present application; adding irrelevant modifications or introducing irrelevant designs in the algorithm or process, but not changing the core design of the algorithm and process, are within the protection scope of the present application.
[0129] In addition, some embodiments of the present application also provide an electronic device. The electronic device can be various forms of digital computers, such as a laptop computer, a desktop computer, a workstation, a personal digital assistant, a server, a blade server, a mainframe computer, and the like. The electronic device can also be various forms of mobile devices, such as a personal digital processing, a cellular phone, a smart phone, a wearable device, and other similar computing devices.
[0130] The electronic device includes one or more processors, and a memory storing computer program instructions which, when executed, cause the processor to perform a question and answer generation method based on reference verification and similarity constraints as provided by 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 an interface for connecting components, including a high-speed interface and a low-speed interface. Various components are connected to each other by different buses, and can be mounted on a common motherboard or otherwise mounted as desired. The processor can process instructions executed within the electronic device, including instructions stored in the memory or on the memory to display a GUI on an external input / output device, such as a display device coupled to the interface. In some other embodiments, multiple processors and / or multiple buses can be used with multiple memories and multiple memories, if desired. Also, multiple electronic devices can be connected, each device providing part of the necessary operations. Among them, the components shown herein, their connections and relationships, and their functions are only examples, and are not intended to limit the implementation of the present application described and / or claimed herein.
[0131] The electronic device can also 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 can be connected by bus or other means, Figure 2 The bus connection is taken as an example in the middle.
[0132] The 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, such as touch screen, keypad, mouse, trackpad, touchpad, pointing stick, one or more mouse buttons, trackball, joystick, and the like input device. The output device 1104 can include a display device, an auxiliary lighting device (e.g., LED), and a tactile feedback device (e.g., a vibration motor), and the like. The display device can 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 can be a touch screen.
[0133] To provide for interaction with a user, the electronic device can be a computer. The computer has a display device (e.g., a cathode ray tube or LCD monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, etc.); and input from the user can be received in any form (e.g., acoustic input, speech input, tactile input, etc.).
[0134] In the embodiments of the present application, the computer program / instruction is stored on the computer readable medium, and the computer program / instruction is executed by the processor to implement the method for generating question and answer based on reference verification and similarity constraint provided by any one or more of the above embodiments. The computer readable medium can be included in the electronic device described in the above embodiments, or can exist separately and not be assembled into the device. The computer readable medium carries one or more computer readable instructions.
[0135] 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 various functions and data processing of the server by running the non-transitory software programs, instructions and modules stored in the memory 1102, so as to implement the program instructions / modules corresponding to the method provided by any one or more of the above embodiments in the embodiments of the present application.
[0136] The memory 1102 can include a program storage area and a data storage area. The program storage area can store an operating system and at least one application required by a function. The data storage area can store data created according to the use of the electronic device. In addition, the memory 1102 can include a high-speed random access memory, and can also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory 1102 can optionally include a memory disposed remotely with respect to the processor 1101, and these remote memories can be connected to the electronic device through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0137] Note that the computer-readable medium described herein can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable medium can be, for example but not limited to, a system, a device, or a computer program product embodied in one or more computer readable media embodying computer readable instructions, data structures, program modules, or other data. Computer-readable storage media include, at least, volatile memory, non-volatile memory, removable or non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer-readable 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 disc read-only memory, digital versatile discs or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information for access by a computing device. In addition, computer-readable storage media can include any appropriate media, which can be used for storing data accessible by a computing device, including a hard disk drive, solid state drive, RAM, ROM, EEPROM, CD-ROM or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information for access by a computing device.
[0138] Computer-readable media includes permanent and non-permanent, removable and non-removable media, which can be implemented by any method or technology for information storage. 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, read-only optical disc, digital versatile disc or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information for access by a computing device.
[0139] Computer program code for carrying out operations of the present application can be written in one or more programming languages or combinations of languages including object-oriented, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as the C programming language or similar programming languages. Program code can be executed entirely on a user computer, partially on a user computer, as a standalone software package, partially on a user computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user computer through any kind of network, including a local area network or a wide area network, or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0140] In the above-described embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. For example, application specific integrated circuits, general purpose computers or any other similar hardware devices can be used. In some embodiments, the software programs of the present application can be executed by a processor to implement the above steps or functions. Similarly, the software programs of the present application (including related data structures) can be stored in a computer-readable recording medium, such as a RAM memory, a magnetic or optical drive or a soft disk and the like. In addition, some steps or functions of the present application can be implemented by hardware, such as a circuit cooperating with a processor to perform the respective steps or functions.
[0141] The computer program product provided by the embodiments of the present application includes one or more computer programs / instructions, which, when executed by a processor, generate all or part of the processes or functions described in the embodiments of the present application. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be magnetic media (such as floppy disk, hard disk, magnetic tape), optical media (such as DVD), or semiconductor media (such as solid state disk) and the like.
[0142] The flowchart or block diagram in the drawings illustrates the architecture, functionality, and operation of possible implementations of devices, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, a segment, or a portion of code, which contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks noted in succession can in fact be executed substantially concurrently, or the blocks can sometimes be executed in reverse order, depending on the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, or combinations of blocks in the block diagrams and / or flowchart illustrations, can be implemented by special-purpose hardware-based systems that perform the specified functions or operations, or combinations of special-purpose hardware and computer instructions.
[0143] The scope of the application is defined by the appended claims rather than by the description set forth herein, and therefore the specification is intended to be illustrative, but not limiting, of the application. Any reference citations herein are hereby incorporated by reference in their entirety. No limitation is intended to any diagrammatic representation of a circuit or semiconductor device, component, or process, except as expressly stated on such diagram. Any reference to "comprising" is intended to mean "including, but not limited to." Any reference to "first", "second", and the like, does not imply that there are only two. It is further noted that the claims can be drafted to exclude any optional element. No language in the specification should be construed as indicating any non-claimed element as essential.
[0144] The above description is only specific embodiments of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present application, which should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be defined by the protection scope of the claims, and the above embodiments should be regarded as exemplary and non-limiting. < / h1>
Claims
1. A method for question generation based on reference verification and similarity constraints, characterized in that, The method comprises the following steps: obtaining document content related to a user input question; generating a reference list based on the document content using a generative model, the reference list comprising one or more reference contents, each reference content being composed of an original text segment extracted from the document content, and the original text segment not being allowed to be rewritten during the generation process; verifying the consistency of each reference content in the reference list with the corresponding original text segment in the document content, and if any reference content fails the verification, triggering the regeneration of the reference list until all reference contents in the reference list pass the consistency verification, including: when any reference content in the reference list fails the consistency verification, triggering the re-execution of the reference list generation process, and re-sending a prompt instruction for generating the reference list to the generative model; the prompt instruction dynamically adjusts the format control requirement, the reference strategy parameter or the generation constraint rule according to the type, position and error characteristics of the previous round of reference verification failure, so as to guide the generative model to output a new reference list until all reference contents in the reference list pass the consistency verification; based on the consistency verification of the reference list, generating a candidate answer based on the user input question, calculating the semantic similarity between the candidate answer and the reference list, and obtaining a similarity score value; comparing the similarity score value with a preset similarity threshold value, if the similarity score value is lower than the similarity threshold value, re-executing the generation and consistency verification process of the reference list and the generation process of the candidate answer until the reference list passes the consistency verification and the similarity score value meets the similarity threshold requirement; outputting the candidate answer that meets the reference consistency verification and similarity requirement, and constituting a question and answer pair with the user input question.
2. The method of claim 1, wherein, Before the step of generating a reference list based on the document content using a generative model, the method further comprises a structured preprocessing of the document content, including: dividing the document content according to paragraphs, sentences or logical levels, extracting the text content of each content unit based on the document layout information and semantic markers, and adding position information to each content unit, the added position information including page number, paragraph number or line number, and starting character offset position in the document; generating a unique identifier for each content unit and calculating the corresponding text hash digest value, and establishing a mapping index structure of the unique identifier, the text hash digest value and the original text content; constructing a document structure tree to record the hierarchical relationship and logical context path between content units, the document structure tree including chapter title path, parent-child structure identifier and logical sequence information.
3. The method of claim 2, wherein, The step of generating a reference list based on the document content using a generative model comprises: in the prompt instruction for generating the reference list input to the generative model, a mandatory reference prompt template containing format control markers is set, the mandatory reference prompt template being used to require that the reference list must be generated in the output result first; The generation model screens a text segment related to the semantic of the question from the structured document content according to the question input by the user, and outputs one or more reference contents which are content-formatted and position information-labeled according to the forced citation prompt template, so as to generate the reference list, the text segment including one or more content units or a continuous text segment within at least one content unit.
4. The method of claim 1, wherein, The consistency verification of each reference content in the reference list and the corresponding text segment in the document content comprises: For each reference content in the reference list, the corresponding text segment in the document content is located based on the carried position information; Based on the text segment and the reference content, a dynamic selection of literal comparison or hash comparison is performed for consistency verification to determine whether the reference content has text-level tampering, addition, deletion or rewriting behavior.
5. The method for question generation based on reference verification and similarity constraints according to claim 1, characterized in that, Based on the reference list passing the consistency verification, a candidate answer is generated based on the question input by the user, the semantic similarity between the candidate answer and the reference list is calculated, and a similarity score value is obtained, which comprises: The reference content in the reference list and the candidate answer are input into a pre-trained semantic encoding model to generate respective semantic vectors; Based on the cosine similarity between the semantic vector of the candidate answer and the semantic vector of each reference content, the semantic similarity score of the candidate answer and each reference content is calculated respectively; The semantic similarity scores are fused according to a preset weighting strategy to calculate the overall semantic similarity score between the candidate answer and the reference list, and the weighting strategy includes determining the weight coefficient of each reference content based on at least one of the position information, the text length and the text density of the reference content in the text.
6. The method for question generation based on reference verification and similarity constraints according to claim 1, characterized in that, The similarity score value is compared with a preset similarity threshold value, if the similarity score value is lower than the similarity threshold value, the generation and consistency verification process of the reference list and the generation process of the candidate answer are re-executed until the reference list passes the consistency verification and the similarity score value meets the similarity threshold requirement, which comprises: Based on the text length, semantic compression rate of the candidate answer, and the number of reference contents in the reference list, semantic density, semantic complexity, semantic dispersion and context tightness of the reference contents, an adjustment function of the similarity threshold value is constructed; The preset basic threshold interval is dynamically adjusted by using the adjustment function to output a currently applicable semantic similarity threshold value; The similarity score value is compared with the currently generated semantic similarity threshold value, if the similarity score value is lower than the semantic similarity threshold value, it is determined that the semantic correlation of the current question and answer result is insufficient, and the whole process of reference list generation, reference consistency verification and candidate answer generation is triggered to be re-executed.
7. The method of claim 6, wherein, The adjustment mechanism of the adjustment function comprises: feedback optimization based on the failure information that the semantic similarity score of the previous round does not meet the semantic similarity threshold, and dynamic adjustment of the generation constraint parameter in the candidate answer generation process, the filtering range of the reference content and the semantic condensation ratio, so as to enhance the semantic convergence and similarity meeting ability between the candidate answer and the reference content in the question and answer generation process.
8. An electronic device, comprising: The electronic device comprises: One or more processors; and a memory having stored computer program instructions that, when executed, cause the processor to perform the question and answer generation method based on reference verification and similarity constraint as claimed in any one of claims 1-7.
9. A computer readable storage medium having stored thereon a computer program and / or instructions, characterized in that, The computer program and / or instructions are executed by the processor to implement the question and answer generation method based on reference verification and similarity constraint as claimed in any one of claims 1-7.
10. A computer program product comprising computer programs and / or instructions, characterized in that, The computer program and / or instructions are executed by the processor to implement the question and answer generation method based on reference verification and similarity constraint as claimed in any one of claims 1-7.
Citation Information
Patent Citations
Validating answers from an artificial intelligence chatbot
US20240419988A1