Double-engine government affair question and answer method based on large model fine tuning and RAG retrieval

Through the dual-engine government question-answering method of large-scale model fine-tuning and RAG retrieval, the problems of answer lag and semantic understanding deviation in government question-answering are solved, and efficient, accurate and secure multimodal answers to government question-answering are achieved, adapting to high-frequency policy changes in the government field.

CN120632050APending Publication Date: 2025-09-12UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 0 Cites 14 Cited by

Patent Information

Application Number
CN202510963414.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-14
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

Existing government question-and-answer technology faces problems such as delayed answers, semantic understanding bias, response delays, and insufficient security when faced with the high-frequency updates and multi-dimensional semantic associations of complex government policies. It is difficult to meet the accuracy, timeliness, and security requirements of government services.

Method used

A dual-engine government question-answering method based on large-scale model fine-tuning and RAG retrieval is adopted. By building a knowledge base in the government affairs field, combining the language understanding capabilities of the large model with a dynamic knowledge update mechanism, multimodal retrieval and precise generation are achieved, and the compliance review model is combined to ensure the accuracy and security of the answers.

Benefits of technology

It achieves efficient and accurate answers to government affairs questions and answers, improves flexibility and reliability in policy timeliness management and multimodal knowledge processing, and adapts to high-frequency policy changes and complex consulting scenarios in the government affairs field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120632050A_ABST
    Figure CN120632050A_ABST
Patent Text Reader

Abstract

The invention discloses a double-engine government affair question and answer method based on large model fine tuning and RAG retrieval, belongs to the field of government affair digitization and natural language processing, and combines large model language understanding generation ability, retrieval enhancement generation technology and a structured reasoning mode. The defects of a traditional government affair question and answer method in the aspects of dynamic policy response, complex semantic understanding and compliance control are overcome. Government affair field knowledge is adapted through large-model fine adjustment, and high-precision and timeliness answering of government affair consultation is realized in combination with vector retrieval and a dynamic updating mechanism. The core innovation of the method lies in deep fusion of a double-engine architecture and dynamic knowledge management, the accuracy and response efficiency of government affair questions and answers are improved on the premise of ensuring policy compliance, and the method is suitable for intelligent upgrading of scenes such as government affair service halls and online consultation platforms.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of digital government technology, and specifically relates to an intelligent question-answering method for government consultation that integrates large-scale model fine-tuning and retrieval enhancement generation technology. Background Art

[0002] As government information technology continues to advance, government Q&A serves as a key gateway for the public to access policy information, and its intelligence directly impacts the effectiveness of government services. Traditional government Q&A technology, primarily based on rule-based matching or static knowledge bases, can provide basic consultation responses, but it gradually exposes technical bottlenecks when addressing the unique complexity of government affairs.

[0003] Early government Q&A methods relied on manual sorting of policy clauses and the construction of keyword matching rules. Although this method has clear logic, it has significant limitations: on the one hand, policy documents are mainly unstructured text, manual parsing is inefficient and difficult to capture dynamic policy changes in real time; on the other hand, public consultations often involve multi-dimensional semantic associations, and keyword matching can only achieve single-level information retrieval, which cannot meet the needs of in-depth understanding of complex issues.

[0004] With the development of natural language processing technology, machine learning-based question-answering models are gradually being applied to government affairs. These models learn semantic features from training data, which has significantly improved their ability to handle multi-round conversations and fuzzy queries. However, they still face core challenges: First, government policies are highly time-sensitive, and traditional models rely on batch updates to knowledge bases, making them difficult to cope with frequent policy changes, resulting in significant delays in answer delivery. Second, the models' semantic understanding of government-specific concepts is biased, making them prone to "policy hallucinations." Furthermore, fixed-architecture models cannot dynamically adapt to different consultation scenarios, and are prone to increased response delays and fluctuating accuracy rates when accessed concurrently.

[0005] At present, the rise of big model technology has brought new directions for government question answering, but direct application still faces adaptation difficulties: general big models lack deep embedding of government affairs knowledge, and the interpretation of policy clauses is prone to deviate from the original intention; the coordination mechanism between the retrieval module and the generation module is insufficient, and it is impossible to effectively utilize the structured reasoning ability of the knowledge base to improve the retrieval accuracy of complex problems; at the same time, the strict requirements of government scenarios on compliance and security urgently require the establishment of a real-time verification mechanism for generated content to avoid the leakage of sensitive information or policy misinterpretation.

[0006] Therefore, designing a question-and-answer method that can adapt to the dynamic changes in government policies by integrating dynamic knowledge updates, semantically enhanced understanding, and compliance control capabilities has become a key issue urgently needed in the field of digital government. An ideal solution must transcend the static nature and limitations of traditional technologies and achieve a deep synergy between automated policy parsing, multimodal retrieval, and precise generation to meet the multiple requirements of government services for accuracy, timeliness, and security. Summary of the Invention

[0007] To address the challenges of high-precision question answering and dynamic knowledge updating faced by current government Q&A methods in complex policy environments, a dual-engine government Q&A method based on large-scale model fine-tuning and RAG retrieval is proposed. By integrating the language understanding capabilities of large models with the accuracy of retrieval technology and combining it with a dynamic knowledge update mechanism, this method achieves efficient and accurate answers to complex government affairs questions, improving flexibility and reliability in policy timeliness management and multimodal knowledge processing. The technical solutions proposed in this invention are as follows:

[0008] Specific content:

[0009] A dual-engine government affairs question-answering method based on large model fine-tuning and RAG retrieval, characterized by comprising the following steps:

[0010] Step 1: Build a knowledge base in the government affairs field and pre-process historical archival materials, manually annotated question-and-answer pairs, and other data, including PDF / Word text parsing, OCR error correction, data cleaning, and structural conversion; generate question-and-answer pairs and extract entity links to the knowledge base, vectorize the text through sliding window segmentation and quantization encoding large models, and store it in the vector library index; combine the government affairs corpus to fine-tune the pre-trained large language model to make it more suitable for government affairs question-and-answer semantic parsing and generation tasks.

[0011] Step 2: Receive the government consultation question input by the user, use the fine-tuned large language model to perform semantic analysis, identify the key issues and contextual elements in the question, and generate the corresponding vectorized query; at the same time, call the timeliness classification model to determine whether the question involves time-sensitive information, providing a basis for subsequent retrieval strategies.

[0012] Step 3: Perform multi-level retrieval. First, based on the query generated in Step 2, the embedding model searches the knowledge base for question-answer pairs and calculates similarity. If the matching result exceeds the set threshold and the question and answer are valid, the answer is directly returned. Otherwise, a secondary retrieval is initiated, integrating the vector library, knowledge base, and entity expansion path using the RAG mechanism to obtain relevant candidate documents. The fine-tuned generative model then generates the final answer by integrating the document content with the user's intent.

[0013] Step 4: Generate a response based on the multi-level search results and user intent. This fine-tuned generation model is used to generate the response content, combining the preset prompt template with the retrieved policy context. Once generated, the compliance review model is used to score the generated content. If the score falls below a set threshold, a manual review process is automatically triggered to ensure the accuracy and reliability of the generated text.

[0014] Step 5: Check the timeliness of policy documents in the knowledge base. If an update condition is triggered (policy expiration or low-confidence retrieval), the new document is parsed, segmented, and vectorized. The vector library and knowledge base are incrementally updated, and invalid data is moved to the archive library to preserve version traceability. The updated content is simultaneously used to fine-tune sample accumulation to continuously improve the performance of the generative model in the new policy context.

[0015] Step 1 of the present invention comprises:

[0016] Step 1-1: Use regular expressions and rule engines to denoise and normalize government text, extract policy clauses, and automatically generate preliminary Q&A pairs.

[0017] In steps 1-2, we construct a set of positive and negative question-answering examples through self-supervised contrastive learning. These examples are vectorized using a large model with quantized encoding and stored in a vector library, supporting subsequent fine-tuning and triggered incremental data loading and updates. During self-supervised training, a contrastive loss function is used to optimize the semantic space distribution, which is defined as follows:

[0018]

[0019] Where D represents the Euclidean distance between positive and negative sample vectors, y∈0, 1 is the label (1 for positive pair, 0 for negative pair), and m is the set interval threshold.

[0020] In addition, cosine similarity is used to calculate semantic matching in vector library construction and retrieval:

[0021]

[0022] Among them, q represents the query vector and v represents the document vector.

[0023] Step 2 of the present invention comprises:

[0024] Step 2-1: Receive the government consultation question input by the user and trigger the text preprocessing process: segment the text, remove stop words, and normalize it. The importance of the terms is measured using the TF-IDF method. The weight calculation is as follows:

[0025]

[0026] Where tf(t, d) is the frequency of term t appearing in document d, df(t) is the number of documents containing the term, and N is the total number of documents in the corpus.

[0027] In step 2-2, the semantic parsing module fine-tuned based on the large model is called to perform dependency parsing and entity recognition on the input question, extract key information, and label entity categories. Entity recognition uses the conditional random field (CRF) model, and the conditional probability model of the output label sequence is as follows:

[0028]

[0029] Among them, x is the input sequence, y is the corresponding label sequence, and f k is the characteristic function, λ k is the feature weight, and Z(x) is the normalization factor (partition function).

[0030] In steps 2-3, the structured key information is input into the Embedding module. Using the Transformer encoder structure, the input semantic vector is calculated through the self-attention mechanism to generate a vectorized query to drive subsequent retrieval. The core attention mechanism formula is as follows:

[0031]

[0032] Among them, Q, K, V are query, key and value matrices respectively, d k Indicates the dimension of the key vector. The module finally outputs the vectorized It will be used to drive subsequent semantic retrieval tasks.

[0033] In steps 2-4, the timeliness classification model is called to determine whether the problem involves timeliness policies, and the corresponding timeliness label is generated based on the judgment result as one of the search conditions. This classification process is modeled as a binary classification task, and the binary cross entropy loss function is used to optimize the model parameters:

[0034]

[0035] Among them, y∈0,1 is the true label, The model predicts the probability value.

[0036] Step 3 of the present invention comprises:

[0037] Step 3-1: Based on the vectorized query, further semantic enhancement is performed by combining the keywords and entity information in the question;

[0038] Step 3-2: A hybrid search method that combines keyword matching and vector similarity, and expands the query scope by leveraging the hierarchical and related relationships of entities in the knowledge base;

[0039] Step 3-3: Filter and sort the results according to the three-level hierarchical search logic of "Question and Answer → Policy Guidelines → Timely Documents", and give priority to returning results that have a high degree of match with recent policy content.

[0040] Step 4 of the present invention comprises:

[0041] In step 4-1, the fine-tuned generative model is called to generate the answer text based on the preset prompt template and the retrieved policy context. To improve the policy compliance of the content, a reinforcement learning mechanism based on policy gradient is used to optimize the generation process. The gradient estimation form is as follows:

[0042]

[0043] Among them, π θ For the generation strategy, R(x) represents the compliance reward function of the generated result.

[0044] In step 4-2, the compliance review model is used to score the generated results at the clause level. The scoring formula used is based on the content overlap and is as follows:

[0045]

[0046] in, is the generated content of the i-th clause, For the corresponding clauses in the standard text, is an indicator function. If the score is lower than the set threshold, a manual review process will be automatically triggered to ensure the accuracy and reliability of the generated text.

[0047] Step 5 of the present invention comprises:

[0048] Step 5-1: Based on the preset policy failure judgment mechanism or when the user query confidence is low, the update logic is triggered to automatically detect the newly uploaded file and complete OCR recognition and text normalization processing;

[0049] Step 5-2: Distribute the document update task to the distributed task queue, perform content segmentation and vectorization operations, and complete the incremental update of the vector library through the Faiss cluster. At the same time, synchronize the maintenance of the newly added or changed entity nodes and their relationship chains in the knowledge base.

[0050] In step 5-3, key sentences, policy clauses, and question-answer pairs are automatically extracted from the updated document, and fine-tuning training samples are generated according to semantic consistency and labeling rules. These samples are stored in the sample library for subsequent continuous fine-tuning of the large model to improve the adaptability of the generated model to the new government context.

[0051] This paper proposes a dual-engine government Q&A method based on large model fine-tuning and RAG retrieval. Compared with the existing technology, it has the following advantages:

[0052] This invention integrates large-model semantic understanding and retrieval technology to build a dynamic knowledge management system and a high-performance question-answering process, and achieves technological breakthroughs through a dual-engine architecture: large-model fine-tuning combined with knowledge base multi-hop reasoning improves question-answering accuracy, and a dual-trigger mechanism based on policy failure and user feedback realizes real-time automatic updating of the knowledge base. At the same time, compliance audits and data encryption are used to ensure security and compliance, realizing "high-precision question-answering + dynamic knowledge update" in the government affairs field, breaking through traditional technical bottlenecks, and being suitable for complex government affairs scenarios with high-frequency policy updates. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 This is a use case demonstration diagram of an embodiment of the present invention;

[0054] Figure 2 This is a flowchart of a semantic parsing module according to an embodiment of the present invention;

[0055] Figure 3 A flow chart of a multi-level search module according to an embodiment of the present invention;

[0056] Figure 4 A flow chart of an answer generation module according to an embodiment of the present invention;

[0057] Figure 5 This is a functional architecture diagram of an embodiment of the present invention;

[0058] Figure 6 This is a screenshot of the question-and-answer interface of an embodiment of the present invention;

[0059] Figure 7 This is a screenshot of the knowledge base management interface of an embodiment of the present invention;

[0060] Figure 8 This is a screenshot of the model fine-tuning interface of an embodiment of the present invention; DETAILED DESCRIPTION

[0061] The preferred embodiments of the present invention are described in detail below with reference to the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more precise definition of the protection scope of the present invention.

[0062] The present invention is implemented including:

[0063] The overall process of the method proposed by the present invention is as follows Figure 1 As shown, the specific construction steps of the dual-engine government affairs question answering method based on large model fine-tuning and RAG retrieval in the embodiment of the present invention are as follows:

[0064] Step 1: Build a knowledge base in the government affairs field and pre-process historical archival materials, manually annotated question-and-answer pairs, and other data, including PDF / Word text parsing, OCR error correction, data cleaning, and structural conversion; generate question-and-answer pairs and extract entity links to the knowledge base, vectorize the text through sliding window segmentation and quantization encoding large models, and store it in the vector library index; combine the government affairs corpus to fine-tune the pre-trained large language model to make it more suitable for government affairs question-and-answer semantic parsing and generation tasks.

[0065] Step 2: Receive the government consultation question input by the user, use the fine-tuned large language model to perform semantic analysis, identify the key issues and contextual elements in the question, and generate the corresponding vectorized query; at the same time, call the timeliness classification model to determine whether the question involves time-sensitive information, providing a basis for subsequent retrieval strategies.

[0066] Step 3: Perform multi-level retrieval. First, based on the query generated in Step 2, the embedding model searches the knowledge base for question-answer pairs and calculates similarity. If the matching result exceeds the set threshold and the question and answer are valid, the answer is directly returned. Otherwise, a secondary retrieval is initiated, integrating the vector library, knowledge base, and entity expansion path using the RAG mechanism to obtain relevant candidate documents. The fine-tuned generative model then generates the final answer by integrating the document content with the user's intent.

[0067] Step 4: Generate a response based on the multi-level search results and user intent. This fine-tuned generation model is used to generate the response content, combining the preset prompt template with the retrieved policy context. Once generated, the compliance review model is used to score the generated content. If the score falls below a set threshold, a manual review process is automatically triggered to ensure the accuracy and reliability of the generated text.

[0068] Step 5: Check the timeliness of policy documents in the knowledge base. If an update condition is triggered (policy expiration or low-confidence retrieval), the new document is parsed, segmented, and vectorized. The vector library and knowledge base are incrementally updated, and invalid data is moved to the archive library to preserve version traceability. The updated content is simultaneously used to fine-tune sample accumulation to continuously improve the performance of the generative model in the new policy context.

[0069] Step 1 of the present invention comprises:

[0070] Step 1-1: Use regular expressions and rule engines to denoise and normalize government text, extract policy clauses, and automatically generate preliminary Q&A pairs.

[0071] In steps 1-2, we construct a set of positive and negative question-answering examples through self-supervised contrastive learning. These examples are vectorized using a large model with quantized encoding and stored in a vector library, supporting subsequent fine-tuning and triggered incremental data loading and updates. During self-supervised training, a contrastive loss function is used to optimize the semantic space distribution, which is defined as follows:

[0072]

[0073] Where D represents the Euclidean distance between positive and negative sample vectors, y∈0, 1 is the label (1 for positive pair, 0 for negative pair), and m is the set interval threshold.

[0074] In addition, cosine similarity is used to calculate semantic matching in vector library construction and retrieval:

[0075]

[0076] Among them, q represents the query vector and v represents the document vector.

[0077] Step 2 of the present invention comprises:

[0078] Step 2-1: Receive the government consultation question input by the user and trigger the text preprocessing process: segment the text, remove stop words, and normalize it. The importance of the terms is measured using the TF-IDF method. The weight calculation is as follows:

[0079]

[0080] Where tf(t, d) is the frequency of term t appearing in document d, df(t) is the number of documents containing the term, and N is the total number of documents in the corpus.

[0081] In step 2-2, the semantic parsing module fine-tuned based on the large model is called to perform dependency parsing and entity recognition on the input question, extract key information, and label entity categories. Entity recognition uses the conditional random field (CRF) model, and the conditional probability model of the output label sequence is as follows:

[0082]

[0083] Among them, x is the input sequence, y is the corresponding label sequence, and f k is the characteristic function, λ k is the feature weight, and Z(x) is the normalization factor (partition function).

[0084] In steps 2-3, the structured key information is input into the Embedding module. Using the Transformer encoder structure, the input semantic vector is calculated through the self-attention mechanism to generate a vectorized query to drive subsequent retrieval. The core attention mechanism formula is as follows:

[0085]

[0086] Among them, Q, K, V are query, key and value matrices respectively, d k Indicates the dimension of the key vector. The module finally outputs the vectorized It will be used to drive subsequent semantic retrieval tasks.

[0087] In steps 2-4, the timeliness classification model is called to determine whether the problem involves timeliness policies, and the corresponding timeliness label is generated based on the judgment result as one of the search conditions. This classification process is modeled as a binary classification task, and the binary cross entropy loss function is used to optimize the model parameters:

[0088]

[0089] Among them, y∈0,1 is the true label, The model predicts the probability value.

[0090] Step 3 of the present invention comprises:

[0091] Step 3-1: Based on the vectorized query, further semantic enhancement is performed by combining the keywords and entity information in the question;

[0092] Step 3-2: A hybrid search method that combines keyword matching and vector similarity, and expands the query scope by leveraging the hierarchical and related relationships of entities in the knowledge base;

[0093] Step 3-3: Filter and sort the results according to the three-level hierarchical search logic of "Question and Answer → Policy Guidelines → Timely Documents", and give priority to returning results that have a high degree of match with recent policy content.

[0094] Step 4 of the present invention comprises:

[0095] In step 4-1, the fine-tuned generative model is called to generate the answer text based on the preset prompt template and the retrieved policy context. To improve the policy compliance of the content, a reinforcement learning mechanism based on policy gradient is used to optimize the generation process. The gradient estimation form is as follows:

[0096]

[0097] Among them, π θ For the generation strategy, R(x) represents the compliance reward function of the generated result.

[0098] In step 4-2, the compliance review model is used to score the generated results at the clause level. The scoring formula used is based on the content overlap and is as follows:

[0099]

[0100] in, is the generated content of the i-th clause, For the corresponding clauses in the standard text, is an indicator function. If the score is lower than the set threshold, a manual review process will be automatically triggered to ensure the accuracy and reliability of the generated text.

[0101] Step 5 of the present invention comprises:

[0102] Step 5-1: Based on the preset policy failure judgment mechanism or when the user query confidence is low, the update logic is triggered to automatically detect the newly uploaded file and complete OCR recognition and text normalization processing;

[0103] Step 5-2: Distribute the document update task to the distributed task queue, perform content segmentation and vectorization operations, and complete the incremental update of the vector library through the Faiss cluster. At the same time, synchronize the maintenance of the newly added or changed entity nodes and their relationship chains in the knowledge base.

[0104] In step 5-3, key sentences, policy clauses, and question-answer pairs are automatically extracted from the updated document, and fine-tuning training samples are generated according to semantic consistency and labeling rules. These samples are stored in the sample library for subsequent continuous fine-tuning of the large model to improve the adaptability of the generated model to the new government context.

[0105] The present invention combines large-scale model fine-tuning and RAG enhanced retrieval technology to significantly improve the accuracy, timeliness and scalability of question and answer in the government field. Compared with the existing technology, the present invention uses a dual-engine collaborative architecture and a dynamic knowledge management mechanism, and uses reinforcement learning to optimize policy compliance and knowledge base expansion semantic associations. It dynamically matches retrieval strategies based on user question characteristics, ensuring the legitimacy of answers while achieving rapid response of the knowledge base. This technology is particularly effective in government environments with high-frequency policy updates and complex consulting scenarios, and can provide precise answers to different types of questions.

[0106] This invention provides a dual-engine government Q&A method based on large-scale model fine-tuning and RAG retrieval. While there are numerous methods and approaches for implementing this technical solution, the above is a preferred embodiment of the invention. Persons skilled in the art will appreciate the need for improvements and refinements without departing from the principles of the invention, and such improvements and refinements are considered within the scope of this invention. Any components not specified in this embodiment may be implemented using existing technologies.

Claims

1. A dual-engine government question answering method based on large model fine-tuning and RAG retrieval, characterized by: The following steps are involved: Step 1: Build a knowledge base in the government affairs field and pre-process historical archival materials, manually annotated question-and-answer pairs, and other data, including PDF / Word text parsing, OCR error correction, data cleaning, and structural conversion; generate question-and-answer pairs and extract entity links to the knowledge base, vectorize the text through sliding window segmentation and quantization encoding large models, and store it in the vector library index; combine the government affairs corpus to fine-tune the pre-trained large language model to make it more suitable for government affairs question-and-answer semantic parsing and generation tasks. Step 2: Receive the government consultation question input by the user, use the fine-tuned large language model to perform semantic analysis, identify the key issues and contextual elements in the question, and generate the corresponding vectorized query; at the same time, call the timeliness classification model to determine whether the question involves time-sensitive information, providing a basis for subsequent retrieval strategies. Step 3: Perform multi-level search. First, based on the query generated in step 2, the embedding model is used to search the knowledge base for question-answer pairs and calculate similarity. If the matching result is higher than the set threshold and the question and answer are valid, the answer is directly returned. Otherwise, a secondary search is initiated, combining the RAG mechanism to fuse the vector library, knowledge base, and entity expansion path to obtain relevant candidate documents. The fine-tuned generation model then generates the final answer by integrating the document content and user intent. Step 4: Generate response text based on the multi-level search results and user intent. The fine-tuned generative model is invoked to combine the preset prompt template with the retrieved policy context to generate the response content. After the generation is completed, the compliance review model is called to score the generated content. If the score is lower than the set threshold, the manual review process will be automatically triggered to ensure the accuracy and reliability of the generated text. Step 5: Check the timeliness of policy documents in the knowledge base. If an update condition is triggered (policy expiration or low-confidence retrieval), the new document is parsed, segmented, and vectorized. The vector library and knowledge base are incrementally updated, and invalid data is moved to the archive library to preserve version traceability. The updated content is simultaneously used to fine-tune sample accumulation to continuously improve the performance of the generative model in the new policy context.

2. The method according to claim 1, characterized in that Step 1 includes: Step 1-1: Use regular expressions and rule engines to denoise and normalize government text, extract policy clauses, and automatically generate preliminary Q&A pairs. In steps 1-2, we construct a set of positive and negative question-answering examples through self-supervised contrastive learning. These examples are vectorized using a large model with quantized encoding and stored in a vector library, supporting subsequent fine-tuning and triggered incremental data loading and updates. During self-supervised training, a contrastive loss function is used to optimize the semantic space distribution, which is defined as follows: Where D represents the Euclidean distance between positive and negative sample vectors, y∈0, 1 is the label (1 for positive pair, 0 for negative pair), and m is the set interval threshold. In addition, cosine similarity is used to calculate semantic matching in vector library construction and retrieval: Among them, q represents the query vector and v represents the document vector.

3. The method according to claim 1, characterized in that Step 2 includes: Step 2-1: Receive the government consultation question input by the user and trigger the text preprocessing process: segment the text, remove stop words, and normalize it. The importance of the terms is measured using the TF-IDF method. The weight calculation is as follows: Where tf(t, d) is the frequency of term t appearing in document d, df(t) is the number of documents containing the term, and N is the total number of documents in the corpus. In step 2-2, the semantic parsing module fine-tuned based on the large model is called to perform dependency parsing and entity recognition on the input question, extract key information, and label entity categories. Entity recognition uses the conditional random field (CRF) model, and the conditional probability model of the output label sequence is as follows: Among them, x is the input sequence, y is the corresponding label sequence, and f k is the characteristic function, λ k is the feature weight, and Z(x) is the normalization factor (partition function). In steps 2-3, the structured key information is input into the Embedding module. Using the Transformer encoder structure, the input semantic vector is calculated through the self-attention mechanism to generate a vectorized query to drive subsequent retrieval. The core attention mechanism formula is as follows: Among them, Q, K, V are query, key and value matrices respectively, d k Indicates the dimension of the key vector. The module finally outputs the vectorized It will be used to drive subsequent semantic retrieval tasks. In steps 2-4, the timeliness classification model is called to determine whether the problem involves timeliness policies, and the corresponding timeliness label is generated based on the judgment result as one of the search conditions. This classification process is modeled as a binary classification task, and the binary cross entropy loss function is used to optimize the model parameters: Among them, y∈0,1 is the true label, The model predicts the probability value.

4. The method according to claim 1, wherein Step 3 includes: Step 3-1: Based on the vectorized query, further semantic enhancement is performed by combining the keywords and entity information in the question. Step 3-2: A hybrid search method that combines keyword matching and vector similarity is used to expand the query scope by leveraging the hierarchical and related relationships of entities in the knowledge base. In step 3-3, the results are filtered and sorted according to the three-level hierarchical search logic of "Q&A → Policy Guidelines → Timely Documents", with priority given to results that have a high degree of match with recent policy content.

5. The method according to claim 1, wherein Step 4 includes: In step 4-1, the fine-tuned generative model is called to generate the answer text based on the preset prompt template and the retrieved policy context. To improve the policy compliance of the content, a reinforcement learning mechanism based on policy gradient is used to optimize the generation process. The gradient estimation form is as follows: Among them, π θ For the generation strategy, R(x) represents the compliance reward function of the generated result. In step 4-2, the compliance review model is used to score the generated results at the clause level. The scoring formula used is based on the content overlap and is as follows: in, is the generated content of the i-th clause, For the corresponding clauses in the standard text, is an indicator function. If the score is lower than the set threshold, a manual review process will be automatically triggered to ensure the accuracy and reliability of the generated text.

6. The method according to claim 1, characterized in that Step 5 includes: Step 5-1: Based on the preset policy failure judgment mechanism or when the user query confidence is low, the update logic is triggered to automatically detect the newly uploaded file and complete OCR recognition and text normalization processing; Step 5-2: Distribute the document update task to the distributed task queue, perform content segmentation and vectorization operations, and complete the incremental update of the vector library through the Faiss cluster. At the same time, synchronize the maintenance of the newly added or changed entity nodes and their relationship chains in the knowledge base. In step 5-3, key sentences, policy clauses, and question-answer pairs are automatically extracted from the updated document, and fine-tuning training samples are generated according to semantic consistency and labeling rules. These samples are stored in the sample library for subsequent continuous fine-tuning of the large model to improve the adaptability of the generated model to the new government context.

Citation Information

Cited By

  • Electric power multi-mode corpus construction query method and system based on sliding window

    CN120873029A

  • Bank intelligent operation knowledge base implementation method and system based on large language model and RAG

    CN121071162A

  • Government affair retrieval enhancement generation framework and method based on knowledge graph

    CN121255999A

  • A government affair retrieval enhancement generation framework and method based on a knowledge graph

    CN121255999B

  • Question and answer method, device and equipment based on RAG operation and maintenance library and medium

    CN121524274A