Intelligent question answering system implementation method for law document optimization and multi-model integration based on RAG technology

By adopting a multi-model integration method based on RAG technology in legal document processing and question-answer systems, problems such as low document loading efficiency and inaccurate text cutting in traditional systems are solved, and a more efficient, accurate and intelligent legal document processing and question-answer system is achieved.

CN119938842APending Publication Date: 2025-05-06SHANGHAI JUECE INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510017344.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-06
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

Traditional legal document processing and question-and-answer systems have problems such as low document loading efficiency, inaccurate text cutting, slow vector storage and retrieval speed, insufficient model understanding and generation capabilities, inaccurate search results, single output methods, insufficient intelligent problem routing, and insufficient system performance evaluation and optimization.

Method used

The implementation method of the intelligent question-answer system integrated with multi-model based legal document optimization based on RAG technology includes document loading optimization, text cutting optimization, vector storage optimization, model understanding and generation capability improvement, search result optimization, output optimization, problem routing intelligence, and system performance evaluation and optimization.

Benefits of technology

It significantly improves document loading efficiency, text cutting accuracy, vector storage and retrieval speed, enhances the understanding and generation ability of the model, ensures the accuracy and relevance of the search results, improves the user experience, and introduces intelligent problem routing and system performance evaluation optimization mechanisms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938842A_ABST
    Figure CN119938842A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of legal document processing and intelligent questioning and answering systems, and provides a legal document optimization and multi-model integration intelligent questioning and answering system implementation method based on an RAG technology, which comprises the following steps of: S1, supporting multi-process and loading process control by screening files, processing coding problems and combining documents in various formats; s2, modifying a text cutter and a semantic cutting technology to enable text slices to better conform to Chinese semantics; s3, adopting multiple processes to establish indexes in batches; according to the law document optimization and multi-model integration intelligent question-answering system implementation method based on the RAG technology, the document loading efficiency, the text cutting accuracy and the vector storage and retrieval speed are remarkably improved, the model understanding and generating capacity is enhanced, the accuracy and correlation of retrieval results are ensured, the user experience is improved, and the method is suitable for popularization and application. And an intelligent question routing and system performance evaluation optimization mechanism is introduced, so that a more efficient, accurate and intelligent legal document processing and question-answering system is constructed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of legal document processing and intelligent question-answering system, and specifically is a method for realizing an intelligent question-answering system based on legal document optimization and multi-model integration based on RAG technology. Background Art

[0002] In the field of legal document processing and intelligent question-answering system technology, traditional question-answering systems often face problems such as low document loading efficiency, inaccurate text segmentation, slow vector storage and retrieval, insufficient model understanding and generation capabilities, inaccurate retrieval results, single output method, insufficiently intelligent question routing, and insufficient system performance evaluation and optimization.

[0003] At present, traditional document loading methods are often lacking in optimization, resulting in low accuracy when processing large amounts of legal documents. Users have to wait for a long time, which affects the user experience. At the same time, text cutting technology is not highly compliant with Chinese semantics, resulting in reduced accuracy in subsequent processing.

[0004] To this end, technicians in this field have proposed an implementation method of an intelligent question-answering system based on legal document optimization and multi-model integration based on RAG technology, aiming to improve the efficiency, accuracy and intelligence of the legal document processing and question-answering system through a series of technical innovations and optimization means to meet user needs and expectations. Summary of the invention

[0005] In order to solve the above technical problems, the present invention provides an implementation method of an intelligent question-answering system based on legal document optimization and multi-model integration of RAG technology, so as to solve the problems that the traditional document loading method in the prior art is often lacking in optimization, resulting in low accuracy when processing a large number of legal documents, and users have to wait for a long time, affecting the user experience; at the same time, the text cutting technology is not highly consistent with Chinese semantics, resulting in reduced accuracy of subsequent processing, and other problems.

[0006] In the first aspect, the present invention proposes a method for implementing an intelligent question-answering system based on legal document optimization and multi-model integration based on RAG technology, including:

[0007] S1. Improve document loading efficiency by filtering files, handling encoding issues and merging documents in multiple formats, supporting multiple processes and loading process control;

[0008] S2. By modifying the text cutter and semantic cutting technology, the text slices are made more consistent with Chinese semantics and the accuracy of subsequent processing is improved;

[0009] S3, use multi-process batch indexing and select the optimal vector model to improve the efficiency of vector storage and retrieval;

[0010] S4. Construct a variety of prompt word templates, combine expert judgment and model testing to select the best solution, and enhance the model's understanding and generation capabilities;

[0011] S5, pre-processing combines retrieval links, and post-processing removes duplications and reorders them to ensure the accuracy and relevance of retrieval results;

[0012] S6. Asynchronously call keyword output and search output, and output the final answer in a streaming manner to improve user experience;

[0013] S7, introduce question routing based on discriminant model, judge according to the professionalism of user questions, and select the most appropriate search path;

[0014] Also includes:

[0015] The evaluation module is used to evaluate, optimize and provide feedback on system performance to improve the accuracy and interpretability of the system.

[0016] Preferably, in step S1, during the document loading optimization phase, in order to further improve the document loading efficiency, parallel processing and intelligent caching technology are introduced, and repeated loading is reduced through an intelligent caching mechanism, thereby significantly improving system performance.

[0017] Preferably, in step S2, in the text cutting optimization stage, in order to further improve the conformity of text slices to Chinese semantics and the accuracy of subsequent processing, a text cutting technology combining a bidirectional long short-term memory network (Bi-LSTM) and a conditional random field (CRF) based on deep learning is introduced. The text cutting technology combines the advantages of Bi-LSTM in sequence modeling and the ability of CRF in label sequence dependency modeling, aiming to more accurately identify vocabulary boundaries in Chinese text, thereby improving the accuracy of text cutting.

[0018] Preferably, in step S3, during the process of vector storage optimization, a method of integrating sparse index and dense index is adopted to improve the accuracy and efficiency of retrieval.

[0019] Preferably, in step S4, during the prompt word instruction optimization phase, the instructions required for high-quality question and answer pairs are continuously optimized by balancing the expert scores and the objective indicator scores, thereby improving the model's ability to handle long texts and complex semantics.

[0020] Preferably, the specific description of step S5 is:

[0021] S5.1. Text preprocessing: perform word segmentation, stop word removal, and stem extraction preprocessing operations on the input query text;

[0022] S5.2, Feature extraction: extract the features of the text;

[0023] S5.3. Construct high-quality question-answer pairs: The SELF-QA framework is introduced to replace the traditional manually written instruction seeds with a large amount of unsupervised knowledge, and more correct and specific legal field data is generated through a large model.

[0024] S5.4, Multi-model retrieval: Use multiple retrieval models to retrieve the preprocessed text;

[0025] S5.5. Result fusion: Fusion the results of multiple retrieval models to obtain a preliminary retrieval result set.

[0026] Preferably, the specific description of step S6 is:

[0027] S6.1. Asynchronous call processing: split the tasks of keyword output and search output, and perform asynchronous call processing on each of them;

[0028] S6.2, Streaming output design: Design a streaming output mechanism to output the processing results to the user step by step, rather than outputting all the results at once;

[0029] S6.3. Result caching and updating: Cache the processing results and update the cache in time when new results are available to ensure that users see the latest results.

[0030] Preferably, the step S7 is specifically described as follows:

[0031] S7.1. Question preprocessing: Preprocess the questions raised by users, including removing stop words, word segmentation, part-of-speech tagging, etc.

[0032] S7.2, feature extraction: extract key features from the preprocessed questions, the features include lexical features, syntactic features, semantic features, etc.;

[0033] S7.3, Discriminant model construction: A discriminant model is constructed based on the extracted features and the vectorized question-answer pair features to judge the professionalism of the user's questions;

[0034] S7.4, Question Routing Strategy: Select the most appropriate search path based on the professional judgment results output by the discriminant model;

[0035] S7.5. Model evaluation and optimization: Use the validation set and test set to evaluate the discriminant model, and optimize the model based on the evaluation results.

[0036] Preferably, the step S8 is specifically described as follows:

[0037] S8.1. Data collection and preprocessing: Collect various data during system operation, including user input, system output, response time, error log, etc., and perform preprocessing, including denoising, standardization, and normalization;

[0038] S8.2, Performance evaluation index construction: According to system requirements, construct appropriate performance evaluation indicators, including accuracy, recall rate, credibility, F1 score, response time, resource occupancy rate, etc.;

[0039] S8.3, Model evaluation and optimization: Evaluate the system model by combining expert subjective scores and objective evaluation indicators, and optimize the model according to the evaluation results, including adjusting model parameters, improving model structure, etc.;

[0040] S8.4. Interpretability evaluation: Evaluate the interpretability of system outputs, that is, whether the system can provide clear and reasonable explanations to explain its output results;

[0041] S8.5, Feedback mechanism design: Design front-end and back-end feedback mechanisms to collect user feedback on system output for further optimization of the system;

[0042] S8.6. Iterative optimization: Based on the evaluation results and feedback, iteratively optimize the system to continuously improve system performance.

[0043] In the second aspect, the present invention proposes an intelligent question-answering system for legal document optimization and multi-model integration based on RAG technology, and a method for implementing the intelligent question-answering system for legal document optimization and multi-model integration based on RAG technology includes:

[0044] Document loading optimization module: responsible for screening files, handling encoding issues and merging documents in multiple formats, supporting multi-process and loading process control, aiming to improve the efficiency of document loading;

[0045] Text cutting optimization module: By modifying the text cutter and adopting semantic cutting technology, the text slices are ensured to be more consistent with Chinese semantics, thereby improving the accuracy of subsequent text processing;

[0046] Vector storage optimization module: It uses a multi-process batch indexing method and selects the optimal model from multiple vector models to improve the efficiency of vector storage and retrieval;

[0047] Prompt word instruction optimization module: build and manage multiple prompt word templates, select the best solution through model testing, so as to enhance the model's understanding of questions and answer generation capabilities;

[0048] Retrieval optimization module: responsible for pre-processing the combined retrieval links, and removing duplicate results and re-ranking them in the post-processing stage to ensure the accuracy and relevance of the retrieval results;

[0049] Output optimization module: realizes asynchronous call of keyword output and search output, and presents the final answer through streaming output, aiming to improve user experience;

[0050] Question routing module: introduces technology based on discriminant models to judge the professionalism of user questions and select the most appropriate search path;

[0051] Evaluation module: used to evaluate, optimize and provide feedback on the overall performance of the system, aiming to continuously improve the accuracy, efficiency and interpretability of the system.

[0052] In a third aspect, the present application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it implements the steps of a method for implementing a legal document optimization and multi-model integrated intelligent question-answering system based on RAG technology as claimed in any one of claims 1 to 9.

[0053] Compared with the prior art, the present invention has the following beneficial effects:

[0054] 1. The present invention significantly improves document loading efficiency and reduces user waiting time through document loading optimization; through parallel processing and intelligent caching technology, it realizes fast loading and intelligent caching of multiple documents, avoids repeated loading, and improves system performance;

[0055] 2. The present invention improves the conformity of text slices to Chinese semantics and the accuracy of subsequent processing through text segmentation optimization; the text segmentation technology combining the bidirectional long short-term memory network (Bi-LSTM) and the conditional random field (CRF) based on deep learning is introduced to more accurately identify the vocabulary boundaries in Chinese texts and improve the accuracy of text segmentation;

[0056] 3. The present invention improves the efficiency of vector storage and retrieval through vector storage optimization; adopts multi-process batch indexing and selects the optimal vector model to achieve rapid retrieval of large-scale legal documents and meet the needs of rapid question and answer;

[0057] 4. The present invention enhances the model's understanding and generation capabilities by optimizing prompt word instructions; constructs multiple prompt word templates, and selects the optimal solution in combination with model testing, thereby improving the model generation quality and the accuracy of question and answer;

[0058] 5. The present invention ensures the accuracy and relevance of search results through search optimization; pre-processing combines search links, and post-processing removes duplications and re-sorts them, thereby improving the accuracy and relevance of search results and enhancing user experience;

[0059] 6. The present invention realizes asynchronous call keyword output and search output through output optimization, and improves user experience and satisfaction through streaming output of the final answer;

[0060] 7. The present invention introduces question routing based on the discriminant model, which makes judgments based on the professionalism of user questions and selects the most appropriate search path, thereby improving the accuracy and efficiency of question answering;

[0061] 8. The present invention includes an evaluation module for evaluating, optimizing and providing feedback on system performance, which can continuously improve the accuracy and interpretability of the system in combination with expert opinions to meet user needs and expectations. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 A flow chart of the method for implementing the intelligent question-answering system based on RAG technology and multi-model integration for legal document optimization of the present invention;

[0063] Figure 2 This is a framework diagram of the intelligent question-answering system for legal document optimization and multi-model integration based on RAG technology of the present invention. DETAILED DESCRIPTION

[0064] The following embodiments of the present invention are described in further detail in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0065] Embodiment: The present invention provides a method for implementing an intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration, such as Figure 1 As shown, including:

[0066] The implementation method of the intelligent question-answering system based on legal document optimization and multi-model integration based on RAG technology includes:

[0067] S1. Improve document loading efficiency by filtering files, handling encoding issues and merging documents in multiple formats, supporting multiple processes and loading process control;

[0068] S2. By modifying the text cutter and semantic cutting technology, the text slices are made more consistent with Chinese semantics and the accuracy of subsequent processing is improved;

[0069] S3, use multi-process batch indexing and select the optimal vector model to improve the efficiency of vector storage and retrieval;

[0070] S4. Construct a variety of prompt word templates, select the best solution based on model testing, and enhance the model's understanding and generation capabilities;

[0071] S5, pre-processing combines retrieval links, and post-processing removes duplications and reorders them to ensure the accuracy and relevance of retrieval results;

[0072] S6. Asynchronously call keyword output and search output, and output the final answer in a streaming manner to improve user experience;

[0073] S7, introduce question routing based on discriminant model, judge according to the professionalism of user questions, and select the most appropriate search path;

[0074] Also includes:

[0075] The evaluation module is used to evaluate, optimize and provide feedback on system performance to improve the accuracy and interpretability of the system.

[0076] Specifically, step S1:

[0077] Document screening: Screen relevant and correctly formatted legal documents from the source;

[0078] Coding processing: uniformly handle the coding issues of documents to ensure there are no garbled characters or format errors;

[0079] Document merging: Merge information scattered in multiple documents;

[0080] Multi-process loading: adopt multi-process and loading process control technology to significantly improve document loading efficiency;

[0081] Step S2:

[0082] Optimize text cutter: adjust the cutting rules to make them more suitable for the semantic characteristics of Chinese text;

[0083] Semantic segmentation technology: Apply advanced semantic analysis technology to ensure that text segmentation is more consistent with Chinese semantics, providing an accurate basis for subsequent processing;

[0084] Step S3:

[0085] Multi-process batch indexing: Use multi-process technology to quickly create document indexes in batches;

[0086] Vector model selection: Select the optimal vector model through comparative testing to improve the efficiency and accuracy of vector storage and retrieval;

[0087] Step S4:

[0088] Diversified prompt words: build a variety of prompt word templates that meet the characteristics of the legal field;

[0089] Model testing and selection: Through actual testing, select the best performing model to enhance the model's ability to understand the problem and generate answers;

[0090] Step S5:

[0091] Pre-processing combined retrieval: optimize the combined retrieval link to ensure the comprehensiveness and accuracy of the retrieval;

[0092] Post-processing de-duplication and re-ranking: deduplicate and re-rank search results to ensure that users obtain the most relevant and accurate information;

[0093] Step S6:

[0094] Asynchronous call technology: realize asynchronous call of keyword output and search output to improve system response speed;

[0095] Streaming output answers: Through streaming output technology, search results are gradually displayed to improve user experience;

[0096] Step S7:

[0097] Introducing the discriminant model: Use the discriminant model to judge the professionalism of user questions;

[0098] Intelligent routing selection: Select the most appropriate search path and model based on the professionalism and type of the question to ensure accurate answers.

[0099] It can be seen from the above that through the above optimization steps, an efficient and accurate legal document intelligent question and answer system based on RAG technology can be built; the system has been carefully designed from document preprocessing, text segmentation, index establishment, model optimization, retrieval link optimization, asynchronous call to question routing, to ensure that the final output answer is both accurate and meets user needs; the system can effectively improve the efficiency of legal document processing and user experience, and provide strong intelligent support for the legal industry.

[0100] Furthermore, in step S1, in the document loading optimization phase, in order to further improve the document loading efficiency, parallel processing and intelligent caching technology are introduced, and repeated loading is reduced through the intelligent caching mechanism, thereby significantly improving system performance;

[0101] The parallel processing technology is as follows: Assuming the total number of documents is N and the number of processor cores is C, the number of documents processed by each core is n = N / C (when N is divisible by C), or dynamically allocated according to specific circumstances; the loading time is T total It can be approximately expressed as T total =max(T 1 ,T 2 ,...,T C ), where T i It represents the time when the ith core processes the document it is responsible for;

[0102] The description of the intelligent caching technology is as follows: establish an intelligent caching system to store recently accessed or frequently accessed documents or parts of their contents; when the system receives a new loading request, first check whether the required document or part of its contents exists in the cache; if it exists, read it directly from the cache to avoid repeated loading; if it does not exist, load it and store the loading result in the cache.

[0103] From the above, we can see that by introducing parallel processing and intelligent caching technology, the efficiency of document loading can be significantly improved; parallel processing enables multiple processor cores to handle document loading tasks simultaneously, greatly shortening the overall loading time; and intelligent caching technology effectively reduces repeated loading by storing and reusing recently accessed or frequently accessed document content, further improving system performance; this strategy that combines parallel processing and cache optimization has significantly improved the response speed and user experience of legal document processing and intelligent question-and-answer systems.

[0104] Furthermore, in step S2, in the text segmentation optimization stage, in order to further improve the conformity of text segments to Chinese semantics and the accuracy of subsequent processing, a text segmentation technology combining a bidirectional long short-term memory network (Bi-LSTM) and a conditional random field (CRF) based on deep learning is introduced. The text segmentation technology combines the advantages of Bi-LSTM in sequence modeling and the ability of CRF in label sequence dependency modeling, aiming to more accurately identify vocabulary boundaries in Chinese texts, thereby improving the accuracy of text segmentation;

[0105] The Bi-LSTM layer: Let the input text sequence be X = {x 1 ,x 2 ,...,x n}, where x i Represents the i-th character in the text; the Bi-LSTM layer will process the sequence from the forward and reverse directions respectively to obtain two hidden state sequences:

[0106]

[0107] Then, concatenate the above two hidden states to get the final hidden state representation:

[0108]

[0109] The CRF layer: The CRF layer takes the output of the Bi-LSTM layer as input and considers the dependency between labels to optimize the prediction results; let the label sequence be Y = {y 1 ,y 2 ,...,y n}, where y i represents the label of the i-th character; the goal of the CRF layer is to maximize the conditional probability of a given input sequence X and the corresponding label sequence Y:

[0110]

[0111] Among them, score(X,Y) is the score function defined by the CRF layer, usually expressed as:

[0112]

[0113] in, and is the label y i The weights and biases of is the label y i and i+1 The transfer score between

[0114] At the same time, during the training process, we use the cross entropy loss function to optimize the model parameters; given a batch of training data {(X 1 ,Y 1 ),(X 2 ,Y 2 ),...,(X m ,Y m )}, the loss function can be expressed as:

[0115]

[0116] Through optimization algorithms such as gradient descent, we can minimize the loss function and learn the optimal model parameters.

[0117] From the above, we can see that by introducing the text segmentation technology that combines Bi-LSTM and CRF based on deep learning, the conformity of text slicing to Chinese semantics and the accuracy of subsequent processing are significantly improved; the Bi-LSTM layer can capture the contextual information of the text sequence from both the forward and reverse directions, while the CRF layer further optimizes the recognition of vocabulary boundaries and takes into account the dependencies between tags; this combination enables the model to more accurately identify vocabulary boundaries in Chinese text, thereby improving the accuracy of text segmentation and providing a more reliable data foundation for subsequent legal document processing and intelligent question and answer.

[0118] Furthermore, in step S3, during the process of vector storage optimization, a method of integrating sparse index and dense index is adopted to improve the accuracy and efficiency of retrieval;

[0119] The index building technique is described as follows: Assume that the data set is D and divide it into n subsets {D 1 ,D 2 ,...,D n}, each subset executes the index construction algorithm Index(D i ), and finally merge the index results of all subsets.

[0120] As can be seen from the above, the efficiency of vector storage and retrieval has been significantly improved by introducing index construction technology. This technology divides large-scale data sets into multiple subsets and executes index construction in parallel on independent computing nodes, effectively utilizing the computing resources of multi-core processors and shortening the time for index construction. Finally, the index results of all subsets are merged to ensure the integrity and consistency of the index. This distributed processing method not only improves the efficiency of vector storage, but also speeds up retrieval, enabling the system to respond to legal document query needs more quickly, improving user experience and system performance.

[0121] Furthermore, in step S4, during the prompt word instruction optimization phase, by balancing the expert scores and the objective indicator scores, the instructions required for high-quality question-answer pairs are continuously optimized, thereby improving the model's ability to process long texts and complex semantics;

[0122] The formula of the attention mechanism is as follows:

[0123] Assume that the input text sequence is X and the output sequence is Y, then the attention weight α can be expressed as:

[0124] α i =softmax(score(x i ,y t ));

[0125] Among them, the score function is used to calculate the input text x i and the output sequence y t The softmax function ensures that the sum of all weights is 1.

[0126] From the above, we can see that by introducing the attention mechanism algorithm, the creativity and accuracy of the optimization of the prompt word instructions in the S4 stage can be significantly improved; this technology can not only enhance the model's understanding and generation capabilities, but also improve the overall performance and user experience of the intelligent question-answering system.

[0127] Further, the specific description of step S5 is:

[0128] S5.1. Text preprocessing: perform preprocessing operations such as word segmentation, stop word removal, and stem extraction on the input query text;

[0129] S5.2, Feature extraction: Extract text features, including TF-IDF features, word embedding features, etc.;

[0130] S5.3. Constructing high-quality question-answer pairs: The SELF-QA framework is introduced to replace the traditional manual instruction seeds with a large amount of unsupervised knowledge, and more correct and specific legal field data is generated through a large model;

[0131] S5.4, Multi-model retrieval: Use multiple retrieval models (including BM25-based models, deep learning-based models, etc.) to retrieve the preprocessed text;

[0132] S5.5. Result fusion: The results of multiple retrieval models are fused to obtain a preliminary retrieval result set; the weighted average formula is as follows: f = α × m 1 +β×m 2 , where α and β are weight coefficients.

[0133] From the above, we can see that by introducing multi-model retrieval and result fusion algorithms in the pre-processing combined retrieval link, and introducing deduplication algorithms, relevance sorting algorithms and optimization adjustment algorithms in the post-processing deduplication and reordering, the creativity and accuracy of retrieval optimization in the S5 stage can be significantly improved; these algorithms and technologies can not only improve the accuracy and relevance of retrieval results, but also improve the overall performance and user experience of the intelligent question and answer system.

[0134] Further, the specific description of step S6 is:

[0135] S6.1. Asynchronous call processing: split the tasks of keyword output and search output, and perform asynchronous call processing on each of them;

[0136] S6.2, Streaming output design: Design a streaming output mechanism to output the processing results to the user step by step, rather than outputting all the results at once;

[0137] S6.3. Result caching and updating: Cache the processing results and update the cache in time when new results are available to ensure that users see the latest results.

[0138] From the above, we can see that by introducing specific steps such as asynchronous call processing, streaming output design, result caching and updating, and user experience optimization in the S6 stage, and combining algorithmic formulas such as load balancing algorithm, real-time evaluation algorithm and user behavior prediction algorithm, the creativity of output optimization and user experience can be significantly improved; these algorithms and technologies can not only improve the system's response speed and throughput, but also improve the overall performance and user satisfaction of the intelligent question and answer system.

[0139] Furthermore, the specific description of step S7 is as follows:

[0140] S7.1. Question preprocessing: Preprocess the questions raised by users, including removing stop words, word segmentation, part-of-speech tagging, etc.

[0141] S7.2, Feature extraction: Extract key features from the preprocessed questions, which may include lexical features, syntactic features, semantic features, etc.;

[0142] S7.3, Discriminant model construction: A discriminant model is constructed based on the extracted features to determine the professionalism of the user's questions;

[0143] S7.4, Question Routing Strategy: Select the most appropriate search path based on the professional judgment results output by the discriminant model;

[0144] S7.5. Model evaluation and optimization: Use the validation set and test set to evaluate the discriminant model, and optimize the model based on the evaluation results.

[0145] From the above, we can see that by introducing specific steps such as question preprocessing, feature extraction, discriminant model construction, question routing strategy, and model evaluation and optimization in the S7 stage, and combining algorithmic formulas and technologies such as attention mechanism, ensemble learning method, semantic matching algorithm, and dynamic routing algorithm, the creativity and accuracy of question routing can be significantly improved; these algorithms and technologies can not only help the system better judge the professionalism of user questions, but also improve the flexibility and scalability of the system.

[0146] Furthermore, the specific description of step S8 is as follows:

[0147] S8.1. Data collection and preprocessing: Collect various data during system operation, including user input, system output, response time, error log, etc., and perform preprocessing, including denoising, standardization, and normalization;

[0148] S8.2, Performance evaluation index construction: According to system requirements, construct appropriate performance evaluation indicators, including accuracy, recall rate, F1 score, response time, resource occupancy rate, etc.;

[0149] S8.3, Model evaluation and optimization: Use evaluation indicators to evaluate the system model, and optimize the model based on the evaluation results, including adjusting model parameters, improving model structure, etc.;

[0150] S8.4. Interpretability evaluation: Evaluate the interpretability of system outputs, that is, whether the system can provide clear and reasonable explanations to explain its output results;

[0151] S8.5, Feedback mechanism design: Design front-end and back-end feedback mechanisms to collect user feedback on system output for further optimization of the system;

[0152] S8.6. Iterative optimization: Based on the evaluation results and feedback, iteratively optimize the system to continuously improve system performance.

[0153] From the above, we can see that by refining the specific steps in the S8 stage and introducing algorithmic formulas and techniques such as the accuracy-recall trade-off formula, the model complexity and generalization ability evaluation formula, the interpretability algorithm formula, and the user satisfaction evaluation formula in the feedback mechanism, the creativity and effectiveness of the system evaluation module can be significantly improved; these algorithms and techniques can not only help the system evaluate its own performance more accurately, but also improve the system's interpretability and user satisfaction.

[0154] Comparative example: Currently, the technical solutions for traditional document loading methods include:

[0155] Step 1: Collect the legal documents that need to be processed from different sources, and then conduct basic format checks and sorting of the documents to ensure that the document format is unified for subsequent processing;

[0156] Step 2: Check and unify the encoding format of all documents to avoid garbled characters caused by inconsistent encoding;

[0157] Step 3: Load the documents one by one into the system for processing in the order of the documents;

[0158] Step 4: Parse the loaded document to extract the text content and other relevant information;

[0159] Step 5: Store the parsed document content in the system database for subsequent retrieval and use;

[0160] Step 6: Build an index for the stored document content to improve retrieval efficiency;

[0161] Step 7: When the user initiates a document query request, the system retrieves the relevant documents from the database and returns them to the user;

[0162] Furthermore, the implementation method of the intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration (implementation) is compared with the current traditional document loading method (comparative example), as follows:

[0163] 1) Document loading efficiency

[0164] Embodiment: By screening files, handling encoding issues and merging documents in multiple formats, supporting multi-process and loading process control, and introducing parallel processing and intelligent caching technology, the document loading efficiency is significantly improved;

[0165] Comparative example: Documents are loaded one by one in order, which lacks optimization and results in low loading efficiency.

[0166] 2) Text cutting accuracy

[0167] Embodiment: By modifying the text cutter and adopting the semantic cutting technology, the text cutting technology combining Bi-LSTM and CRF based on deep learning is introduced to improve the conformity of text slices to Chinese semantics and the accuracy of subsequent processing;

[0168] Comparative example: No specific text segmentation optimization technology is mentioned, and there may be a problem of low conformity to Chinese semantics;

[0169] 3) Vector storage and retrieval efficiency

[0170] Embodiment: Multi-process batch indexing is adopted, the optimal vector model is selected, and index building technology is introduced to improve the efficiency of vector storage and retrieval;

[0171] Comparative example: indexing the stored document content, but no specific optimization measures are mentioned, and the retrieval efficiency may be low;

[0172] 4) Model understanding and generation capabilities

[0173] Example: Construct multiple prompt word templates, select the best solution based on model testing, and introduce the attention mechanism to enhance the model's understanding and generation capabilities;

[0174] Comparative example: No optimization measures for model understanding and generation capabilities were mentioned;

[0175] 5) Accuracy of search results

[0176] Embodiment: Pre-processing combines retrieval links, and post-processing removes duplication and reorders them, ensuring the accuracy and relevance of retrieval results;

[0177] Comparative example: No specific measures for optimizing search results are mentioned, which may result in inaccurate or low relevance results;

[0178] 6) User Experience

[0179] Embodiment: asynchronously calling keyword output and search output, and outputting the final answer in a streaming manner, thereby improving the user experience;

[0180] Comparative example: No optimization measures for user experience are mentioned, and there may be problems such as single output method and slow response speed;

[0181] 7) Intelligent problem routing

[0182] Embodiment: Introducing question routing based on a discriminant model, judging according to the professionalism of user questions, selecting the most appropriate search path, and improving the accuracy and efficiency of question answering;

[0183] Comparative example: No optimization measures for problematic routing are mentioned, which may lack intelligence;

[0184] 8) System performance evaluation and optimization

[0185] Embodiment: including an evaluation module to evaluate, optimize and provide feedback on system performance, and to continuously improve the accuracy and interpretability of the system;

[0186] Comparative example: No measures for system performance evaluation and optimization were mentioned.

[0187] And according to the above content, the system test was carried out to obtain the effect scores of the embodiment and the comparative example at various comparison points, and the improvement percentage of the embodiment relative to the comparative example was calculated as follows:

[0188] Contrast Points Example rating (%) Comparison score (%) Percentage increase Document loading efficiency 9.5 6.0 58% Text cutting accuracy 9.0 7.0 29% Vector storage and retrieval efficiency 9.2 7.5 23% Model understanding and generation capabilities 8.8 6.5 35% Accuracy of search results 9.3 7.8 19% User Experience 9.0 7.2 25% Question routing intelligence 8.5 6.0 42% System performance evaluation and optimization 9.0 7.0 29%

[0189] From the above, it can be seen that the implementation method of the intelligent question-answering system for legal document optimization and multi-model integration based on RAG technology in the embodiment of the present invention has achieved significant improvements in document loading efficiency, text segmentation accuracy, vector storage and retrieval efficiency, model understanding and generation capabilities, retrieval result accuracy, user experience, question routing intelligence, and system performance evaluation and optimization compared to the comparative example. This embodiment constructs a more efficient, accurate, and intelligent legal document processing and question-answering system, which greatly improves the user experience and system performance.

[0190] In summary, compared with the existing technology, the method for implementing the intelligent question-answering system for legal document optimization and multi-model integration based on RAG technology of the present invention significantly improves the document loading efficiency, text segmentation accuracy, vector storage and retrieval speed, enhances the model's understanding and generation capabilities, ensures the accuracy and relevance of retrieval results, improves user experience, and introduces intelligent question routing and system performance evaluation optimization mechanism, thereby constructing a more efficient, accurate and intelligent legal document processing and question-answering system.

[0191] An intelligent question-answering system based on legal document optimization and multi-model integration based on RAG technology, such as Figure 2 As shown, the method for implementing the intelligent question answering system using the above-mentioned legal document optimization and multi-model integration based on RAG technology includes:

[0192] Document loading optimization module: responsible for screening files, handling encoding issues and merging documents in multiple formats, supporting multi-process and loading process control, aiming to improve the efficiency of document loading;

[0193] Text cutting optimization module: By modifying the text cutter and adopting semantic cutting technology, the text slices are ensured to be more consistent with Chinese semantics, thereby improving the accuracy of subsequent text processing;

[0194] Vector storage optimization module: It uses a multi-process batch indexing method and selects the optimal model from multiple vector models to improve the efficiency of vector storage and retrieval;

[0195] Prompt word instruction optimization module: build and manage multiple prompt word templates, select the best solution through model testing, so as to enhance the model's understanding of questions and answer generation capabilities;

[0196] Retrieval optimization module: responsible for pre-processing the combined retrieval links, and removing duplicate results and re-ranking them in the post-processing stage to ensure the accuracy and relevance of the retrieval results;

[0197] Output optimization module: realizes asynchronous call of keyword output and search output, and presents the final answer through streaming output, aiming to improve user experience;

[0198] Question routing module: introduces technology based on discriminant models to judge the professionalism of user questions and select the most appropriate search path;

[0199] Evaluation module: used to evaluate, optimize and provide feedback on the overall performance of the system, aiming to continuously improve the accuracy, efficiency and interpretability of the system.

[0200] In this embodiment, the implementation method of the intelligent question-answering system for optimizing legal documents and integrating multiple models based on RAG technology includes a processor and a memory, wherein the processor includes a kernel, and the kernel retrieves the corresponding program unit from the memory. One or more kernels may be provided, and the implementation method of the intelligent question-answering system for optimizing legal documents and integrating multiple models based on RAG technology is implemented by adjusting kernel parameters.

[0201] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0202] An embodiment of the present application provides a processor configured to execute the above-mentioned RAG technology-based legal document optimization and multi-model integrated intelligent question-answering system implementation method.

[0203] An embodiment of the present application provides a machine-readable storage medium having instructions stored thereon, which, when executed by a processor, configures the processor to execute the above-mentioned method for implementing the intelligent question-answering system for legal document optimization and multi-model integration based on RAG technology.

[0204] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0205] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0206] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0207] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0208] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0209] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0210] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. 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 (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0211] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0212] The embodiments of the present invention are provided for the purpose of illustration and description. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations of the present invention. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present invention.

Claims

1. A method for implementing an intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration, characterized by: include: S1. Support multi-process and loading process control by filtering files, handling encoding issues and merging documents in multiple formats; S2, by modifying the text cutter and semantic cutting technology to make the text slices more consistent with Chinese semantics; S3, use multi-process batch indexing and select the optimal vector model; S4, construct multiple prompt word templates and select the best solution based on model testing; S5, pre-processing to combine retrieval links, post-processing to remove duplication and re-order; S6, asynchronously call keyword output and search output, and output the final answer through streaming; S7. Judge based on the professionalism of the user's question and select the most appropriate search path.

2. The method for implementing the intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration as claimed in claim 1, characterized in that: In step S1, during the document loading optimization phase, parallel processing and intelligent caching technology are introduced to reduce repeated loading through the intelligent caching mechanism, thereby significantly improving system performance.

3. The method for implementing the intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration as claimed in claim 1, characterized in that: In step S2, the text cutting optimization stage, a text cutting technology combining a bidirectional long short-term memory network based on deep learning and a conditional random field is introduced. The text cutting technology combines the advantages of Bi-LSTM in sequence modeling and the ability of CRF in label sequence dependency modeling.

4. The method for implementing the intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration as claimed in claim 1, characterized in that: In step S3, during the process of vector storage optimization, a method of integrating sparse index and dense index is adopted to improve the accuracy and efficiency of retrieval.

5. The method for implementing the intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration as claimed in claim 1, characterized in that: In step S4, during the prompt word instruction optimization phase, the instructions required for high-quality question and answer pairs are continuously optimized by balancing the expert scores and the objective indicator scores, thereby improving the model's ability to handle long texts and complex semantics.

6. The method for implementing the intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration as claimed in claim 1, characterized in that: The specific description of step S5 is: S5.

1. Text preprocessing: perform word segmentation, stop word removal, and stem extraction preprocessing operations on the input query text; S5.2, Feature extraction: extract the features of the text; S5.

3. Construct high-quality question-answer pairs: The SELF-QA framework is introduced to replace the traditional manually written instruction seeds with a large amount of unsupervised knowledge, and more correct and specific legal field data is generated through a large model. S5.4, Multi-model retrieval: Use multiple retrieval models to retrieve the preprocessed text; S5.

5. Result fusion: Fusion the results of multiple retrieval models to obtain a preliminary retrieval result set.

7. The method for implementing the intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration as claimed in claim 1, characterized in that: The specific description of step S6 is: S6.

1. Asynchronous call processing: split the tasks of keyword output and search output, and perform asynchronous call processing on each of them; S6.2, Streaming output design: Design a streaming output mechanism to output the processing results to the user step by step, rather than outputting all the results at once; S6.

3. Result caching and updating: Cache the processing results and update the cache in time when there are new results.

8. The method for implementing the intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration as claimed in claim 1, characterized in that: The specific description of step S7 is as follows: S7.

1. Question preprocessing: preprocess the questions raised by users; S7.2, feature extraction: extract key features from the preprocessed questions, the features include lexical features, syntactic features, and semantic features; S7.3, Discriminant model construction: A discriminant model is constructed based on the extracted features to determine the professionalism of the user's questions; S7.4, Question Routing Strategy: Select the most appropriate search path based on the professional judgment results output by the discriminant model; S7.

5. Model evaluation and optimization: Use the validation set and test set to evaluate the discriminant model, and optimize the model based on the evaluation results.

9. The method for implementing the intelligent question-answering system based on RAG technology for legal document optimization and multi-model integration as claimed in claim 1, characterized in that: The specific description of step S8 is as follows: S8.

1. Data collection and preprocessing: Collect various data during system operation, including user input, system output, response time, error log, and perform preprocessing; S8.2, Performance evaluation index construction: Construct appropriate performance evaluation indicators according to system requirements; S8.3, Model evaluation and optimization: Evaluate the system model by combining expert subjective scores and objective evaluation indicators, and optimize the model based on the evaluation results; S8.

4. Interpretability evaluation: Evaluate the interpretability of system outputs, that is, whether the system can provide clear and reasonable explanations to explain its output results; S8.

5. Feedback mechanism design: Design front-end and back-end feedback mechanisms to collect user feedback on system output; S8.

6. Iterative optimization: Based on the evaluation results and feedback, iteratively optimize the system to continuously improve system performance.

10. An intelligent question-answering system based on legal document optimization and multi-model integration based on RAG technology, characterized by: A method for implementing an intelligent question-answering system for legal document optimization and multi-model integration based on RAG technology according to any one of claims 1 to 9 comprises: Document loading optimization module: responsible for screening files, handling encoding issues and merging documents in multiple formats, supporting multi-process and loading process control; Text cutting optimization module: by modifying the text cutter and adopting semantic cutting technology, the text slices are ensured to be more in line with Chinese semantics; Vector storage optimization module: uses a multi-process batch indexing method and selects the optimal model from multiple vector models; Prompt word instruction optimization module: build and manage multiple prompt word templates, and select the optimal solution through model testing; Retrieval optimization module: responsible for pre-processing the combined retrieval link, and removing duplicate results and re-ranking them in the post-processing stage; Output optimization module: implements asynchronous call of keyword output and search output, and presents the final answer through streaming output; Question routing module: introduces technology based on discriminant models to judge the professionalism of user questions and select the most appropriate search path; Evaluation module: used to evaluate, optimize and provide feedback on the overall performance of the system.