A question and answer method, system, storage medium and computer device
By employing multi-dimensional retrieval and dynamic weight adjustment, the problems of inaccurate retrieval results and poor flexibility in RAG technology are solved, improving the accuracy and efficiency of question-and-answer generation, and enabling flexible system configuration and efficient operation and maintenance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-26
- Publication Date
- 2026-03-27
AI Technical Summary
Existing RAG technology suffers from inaccurate search results and poor search flexibility in practical applications, making it difficult to improve the accuracy of responses generated by language models.
By retrieving document data under multiple preset search dimensions, dynamically adjusting the weight vector, and combining keywords in the question and answer statements, the system can adaptively match different question and answer scenarios. A graphical interface is used for system configuration, enabling flexible customization and dynamic adjustment of the process.
It improves the accuracy and reliability of document retrieval, enhances the accuracy and efficiency of question-and-answer generation, meets the differentiated needs of different scenarios, reduces the difficulty of system operation and maintenance, and enhances the maintainability and adaptability of the system.
Smart Images

Figure CN121413781B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and more specifically, to a question-answering method, system, storage medium, and computer device. Background Technology
[0002] With the development of artificial intelligence technology, large-scale language models are increasingly being used in the field of text question answering. Question answering language models designed for specific technical fields typically perform well on their own private databases within that field. However, when applied to other technical fields or scenarios with high accuracy requirements, they may pose a risk of inaccurate answers. Therefore, to improve the generation accuracy of question answering language models across various domains, Retrieval Augmented Generation (RAG) technology offers a new solution. RAG technology can improve the accuracy of answer results by introducing external knowledge bases to bridge the gap between the model's internal knowledge (i.e., its private database) and real-world information.
[0003] However, existing RAG technology still suffers from inaccurate search results and poor search flexibility in practical applications, which means that the accuracy of the answers generated by the language model can still be improved. Summary of the Invention
[0004] In view of this, this application provides a question-answering method, system, storage medium, and computer device, aiming to solve the problems of inaccurate search results and poor search flexibility in the practical application of existing RAG technology, and to improve the accuracy of the generated answer results.
[0005] Specifically, this application is implemented through the following technical solution:
[0006] In a first aspect, embodiments of this disclosure provide a question-and-answer method, including:
[0007] Receive a question-and-answer request initiated by a user; the question-and-answer request includes question-and-answer statements and question-and-answer mode parameters;
[0008] When the question-and-answer mode parameter is the first preset mode, the initial weight vectors corresponding to multiple preset search dimensions are determined according to the target intent type corresponding to the question-and-answer statement; the multiple preset search dimensions include at least the document content dimension, the document metadata dimension, and the keyword dimension;
[0009] Based on the question and answer keywords in the question and answer statements, the initial weight vector corresponding to each preset search dimension is adjusted to obtain the target weight vector corresponding to each preset search dimension;
[0010] Based on the target weight vector and the document data of each document to be matched under each preset search dimension, multiple target document fragments that match the question and answer statement are determined.
[0011] Using a large language model, based on the multiple target document fragments, an answer result matching the question-and-answer request is generated.
[0012] Secondly, embodiments of this disclosure provide a question-answering system, which includes an interface service module, a dynamic workflow orchestration module, a retrieval service module, and a generation service module; the dynamic workflow orchestration module includes at least a request receiving node, a conditional branch node, a retrieval service invocation node, and a generation service invocation node; wherein:
[0013] The interface service module is used to receive question-and-answer requests initiated by users; the question-and-answer request includes question-and-answer statements and question-and-answer mode parameters;
[0014] The request receiving node is used to send the question-and-answer mode parameters to the conditional branch node;
[0015] The conditional branch node is used to invoke the search service module using the search service invocation node when the question-and-answer mode parameter is the first preset mode;
[0016] The retrieval service module is used to determine initial weight vectors corresponding to multiple preset retrieval dimensions based on the target intent type corresponding to the question and answer statement; the multiple preset retrieval dimensions include at least document content dimension, document metadata dimension, and keyword dimension; adjust the initial weight vectors corresponding to each preset retrieval dimension according to the question and answer keywords in the question and answer statement to obtain the target weight vectors corresponding to each preset retrieval dimension; based on the target weight vectors and the document data of each document to be matched under each preset retrieval dimension, determine multiple target document fragments that match the question and answer statement, and call the generation service module using the generation service call node;
[0017] The generation service module is used to generate answer results that match the question-and-answer request based on the multiple target document fragments using a large language model.
[0018] Thirdly, an optional implementation of this disclosure also provides a computer-readable storage medium, a processor, and a memory, on which a computer program is stored, which, when executed by the processor, implements the steps of the first aspect above, or any possible implementation of the first aspect.
[0019] Fourthly, an optional implementation of this disclosure also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the first aspect above, or any possible implementation of the first aspect.
[0020] For a description of the effects of the aforementioned question-and-answer system, computer-readable storage medium, and computer device, please refer to the following explanation of the question-and-answer method; it will not be repeated here.
[0021] The question-answering method, system, storage medium, and computer device provided in this disclosure, compared to existing technologies that utilize RAG technology and introduce external knowledge bases for question-answering retrieval and result generation, suffer from inaccurate retrieval results, poor retrieval flexibility, and low accuracy of generated answers, combine document data from multiple preset retrieval dimensions for searching. This fully considers the impact of different dimensions of the document on the retrieval results, thereby improving the accuracy and reliability of document retrieval. Furthermore, by dynamically determining the initial weight vectors of multiple preset retrieval dimensions and dynamically adjusting the initial weights in real time based on question-answering keywords, adaptive optimization of retrieval strategies for different question-answering scenarios can be achieved, enabling adaptive matching of different retrieval scenarios and improving retrieval flexibility and scenario adaptability. Thus, by combining multiple preset retrieval dimensions and flexibly adjusting dimension weights, the accuracy and scenario matching of target document fragments supplied to large-scale language models can be improved, thereby enhancing the accuracy of the final generated answer results.
[0022] Furthermore, the question-answering method, system, storage medium, and computer device provided in this disclosure introduce a dual-mode question-answering mechanism that includes deep retrieval and fast question answering. This allows for intelligent selection of the processing path based on question-answering mode parameters during question-answer generation. Specifically, in deep retrieval mode, a complete adaptive hybrid retrieval process is executed, ensuring high accuracy and relevance of the returned document fragments through multi-dimensional weight adjustments. This provides sufficient and accurate contextual information for the large language model, thereby generating detailed and reliable answer results. In fast question-answering mode, the retrieval process is skipped, and the language model is directly invoked for rapid generation of answer results, significantly reducing response latency and achieving rapid response. The two question-answering modes are dynamically routed through a unified process engine, satisfying users' differentiated needs for different types of question-answering scenarios while achieving reasonable allocation and optimized utilization of computing resources, effectively improving overall question-answering efficiency and user experience.
[0023] Furthermore, the question-answering method, system, storage medium, and computer device provided in this disclosure, by weightedly fusing the first target similarity obtained from multi-dimensional hybrid retrieval with the importance score of document fragments, not only fully utilizes the comprehensive advantages of multi-dimensional retrieval in terms of semantic relevance, keyword matching, and metadata association, but also effectively introduces the fragment authority and logical coherence reflected in the document structure information. This achieves the optimal balance between relevance and readability, accuracy and completeness of the retrieval results, providing higher quality and better structured contextual basis for subsequent large-scale language model to generate answers, thereby improving the accuracy and practicality of the final answer results.
[0024] Furthermore, the question-answering method, system, storage medium, and computer device provided in this disclosure, by establishing a monitoring mechanism for any stage of the question-answering process, continuously collect and analyze the operational indicator information of each question-answering step. This enables timely detection and alerts for anomalies generated during the question-answering process, thereby addressing the problem of weak system fault perception and recovery capabilities. It not only achieves transparent perception of system operating status and rapid anomaly localization but also effectively supports system fault early warning and preventative maintenance, significantly improving system maintainability and operational stability. Simultaneously, through the continuous accumulation and analysis of performance data from each processing stage, it provides data support for subsequent system optimization and iteration, thereby further enhancing the system's adaptability and long-term operational efficiency while ensuring service continuity.
[0025] Furthermore, the question-answering method, system, storage medium, and computer device provided in this disclosure, through a graphical interface, allow for visual configuration and logical orchestration of decoupled functional nodes such as request receiving nodes, conditional branch nodes, and service calling nodes, as well as / or independent microservice modules. This enables users to intuitively and conveniently modify process logic, add functional nodes, or replace service components according to actual needs, achieving flexible customization and dynamic adjustment of system business processes. Thus, the visual configuration method not only significantly reduces the technical threshold for system operation and maintenance and functional expansion, but also ensures high scalability and ease of maintenance of the system architecture through a real-time effective mechanism, effectively solving the technical problems of difficult process changes and high system coupling under traditional hard-coded architectures. Attached Figure Description
[0026] Figure 1 A flowchart of a question-and-answer method provided by an embodiment of this disclosure is shown;
[0027] Figure 2 A schematic diagram of a question-answering system provided in an embodiment of this disclosure is shown;
[0028] Figure 3 A detailed flowchart of a question-and-answer method provided in an embodiment of this disclosure is shown;
[0029] Figure 4 This illustration shows a flowchart of a monitoring service for some services in a question-and-answer system provided by an embodiment of this disclosure;
[0030] Figure 5 A schematic diagram of the structure of a computer device provided in an embodiment of this disclosure is shown. Detailed Implementation
[0031] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0032] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0033] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0034] Research has revealed that as intelligent question-answering systems are increasingly applied in enterprise knowledge management and professional fields, users' demands for answer accuracy are rising. While large language models offer reliable performance in text generation, they are often limited by the knowledge reserves of their internal databases, leading to unreasonable generated results in different application scenarios or when generating high-precision results. To address this issue, RAG technology offers a novel approach. RAG technology improves the factual accuracy of the generated results by introducing external knowledge bases for data retrieval and feeding the retrieval results to large language models. However, existing question-answering systems based on RAG technology still have significant limitations in practical applications. For example, the retrieval process typically relies on a single dimension of document content, lacking comprehensive utilization of multi-dimensional information such as document metadata and keywords, and cannot flexibly match various retrieval needs, greatly reducing the accuracy of retrieval results. Furthermore, existing question-answering systems generally employ a tightly coupled architecture, directly linking retrieval and generation modules through hard coding, resulting in poor system scalability and maintainability. Any process adjustment or component upgrade requires modification of the core code, increasing the difficulty and cost of technology iteration. Meanwhile, the lack of a monitoring mechanism for the operational status of critical service nodes makes it difficult to locate and handle faults in a timely manner when service anomalies occur, affecting the overall availability of the system.
[0035] While existing research has attempted to improve retrieval performance by optimizing retrieval algorithms or introducing multi-path recall strategies, it has not fundamentally solved the problem of the simplification of retrieval strategies, nor has it effectively addressed the differentiated retrieval needs across various scenarios. Furthermore, the tightly coupled architecture makes the system difficult to adapt to rapidly changing business requirements, while the lack of monitoring mechanisms increases the uncertainty of system operation and maintenance. These factors collectively limit the effectiveness of question-answering systems in practical applications, resulting in the need for further improvement in the accuracy of answers generated by large language models.
[0036] Based on the above research, to solve the aforementioned technical problems, this disclosure provides a question-answering method, system, storage medium, and computer device. By combining document data of the document to be matched under multiple preset search dimensions for retrieval, the impact of different dimensional information of the document to be matched on the retrieval results can be fully considered, thereby improving the accuracy and reliability of document retrieval. Furthermore, by dynamically determining the initial weight vectors of multiple preset search dimensions and dynamically adjusting the initial weights in real time based on the question-answering keywords in the question-answering statements, adaptive optimization of the retrieval strategy can be achieved for different question-answering scenarios, achieving the goal of adaptively matching different retrieval scenarios, thereby improving retrieval flexibility and scenario adaptability. Thus, by combining multiple preset search dimensions and flexibly adjusting the dimension weights, the accuracy and scenario matching degree of the target document fragments supplied to the large language model can be improved, thereby improving the accuracy of the final generated answer results. Through a graphical interface, the decoupled request receiving nodes, conditional branch nodes, service call nodes, and other functional nodes and / or independent microservice modules can be visually configured and logically orchestrated, allowing users to intuitively and conveniently modify process logic, add functional nodes, or replace service components according to actual needs, realizing flexible customization and dynamic adjustment of system business processes.
[0037] The shortcomings of the above solutions are the result of the inventor's practical experience and careful research. Therefore, the discovery process of the above problems and the solutions proposed in this disclosure below are all contributions made by the inventor to this disclosure.
[0038] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0039] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0040] It should be noted that the specific terms mentioned in the embodiments of this disclosure include:
[0041] n8n is an open-source, node-based, low-code workflow automation platform that allows users to connect different applications and services through a visual drag-and-drop interface to create complex automated processes without extensive programming.
[0042] To facilitate understanding of this embodiment, a question-and-answer method disclosed in this disclosure will first be introduced.
[0043] like Figure 1The flowchart shown is a question-and-answer method provided in an embodiment of this disclosure, which may include the following steps:
[0044] S101: Receive a question-and-answer request initiated by the user; the question-and-answer request includes the question-and-answer statement and the question-and-answer mode parameter.
[0045] Here, the question-and-answer method provided in this embodiment can be applied to professional fields with precise knowledge support, scenarios with high accuracy requirements for answers, and everyday question-and-answer interaction scenarios.
[0046] A question-and-answer request refers to a user-initiated knowledge query interaction request, which includes natural language question-and-answer statements to express the query content and a question-and-answer mode parameter (Task_mode) to indicate the question-and-answer request processing mode. The question-and-answer request processing mode is used to instruct the model for retrieving and generating questions and answers for the request; different question-and-answer request processing modes correspond to different question-and-answer processing flows.
[0047] Specifically, the question-and-answer mode parameters can be configuration parameters used to control the type of response process. For example, the question-and-answer mode parameters can include a first preset mode and a second preset mode. The first preset mode can be a deep search mode, and the second preset mode can be a quick question-and-answer mode. Different preset modes can be represented by different parameter values. For example, when the parameter is the first value, a deep search mode that includes multi-dimensional search, reordering, and merging can be triggered; when the parameter is the second value, a quick response mode that skips the search step is enabled. Users can flexibly choose the interaction mechanism of the response strategy according to their own query needs, thereby achieving the technical effect of dynamically allocating system resources and balancing response accuracy and response speed according to user needs.
[0048] In practice, when a user has a question-and-answer requirement, they can initiate a question-and-answer request that includes the question-and-answer statement and question-and-answer mode parameters. After receiving the question-and-answer request, subsequent steps S102~S105 can be used to process the question and answer and generate the result.
[0049] Optionally, this application also provides a question-answering system matching the question-answering method. This system may include decoupled interface service modules, dynamic workflow orchestration modules, retrieval service modules, generation service modules, and monitoring service modules; each module can be used independently as a pre-configured microservice. The interface service module can be used to receive user requests, determine the target intent type corresponding to the user request, and distribute the user request and target intent type to the workflow engine for processing. The retrieval service module can specifically be used to achieve mixed retrieval under multiple preset retrieval dimensions based on document content vectors, document metadata vectors, and BM25 keyword matching. The dynamic workflow orchestration module schedules the question-answering processing flow based on a visual workflow engine. The dynamic workflow orchestration module may include request receiving nodes, conditional branch nodes, retrieval service call nodes, and generation service call nodes. The generation service module can correspond to the API of a large language model, thereby generating answer results using the large language model. The monitoring service module is used to implement a monitoring mechanism. Different question-answering processing steps in the question-answering method provided in this application can be executed using different modules or nodes in the question-answering system. The following section will explain the roles of different modules or nodes in a question-and-answer system, based on the introduction to question-and-answer processing methods.
[0050] For S101, user-initiated question-and-answer requests can be received through the interface service module. Specifically, the interface service module can be an Application Programming Interface (API) service module, which provides API call services to receive question-and-answer requests and call other modules in the question-and-answer system. For example, a user can initiate a question-and-answer request by calling the interface service module. The interface service module can then receive the user-initiated request. Next, the interface service module can send the question-and-answer request to the workflow engine, which schedules the dynamic workflow orchestration module. The request receiving node in the dynamic workflow orchestration module can send the question-and-answer pattern parameters from the request to the conditional branch node. The request receiving node receives the question-and-answer request from the interface service module and passes the question-and-answer statements and question-and-answer pattern parameters to other nodes for processing. The conditional branch node determines the question-and-answer processing flow based on the processing mode indicated by the question-and-answer pattern parameters.
[0051] For example, an interface service module can be used to receive user-initiated question-and-answer requests, and then preprocess the question-and-answer statements in the request. This preprocessing can include, but is not limited to, sensitive word filtering, deduplication, and lightweight intent recognition. Lightweight intent recognition can be implemented by calling a pre-trained intent recognition model (such as Bidirectional Encoder Representations from Transformers (BETR)) or based on traditional semantic analysis and intent recognition methods. For instance, the interface service module can perform real-time semantic parsing of the question-and-answer request to determine the question-and-answer statements and Task_mode. Then, sensitive word filtering and deduplication are performed on the question-and-answer statements to obtain the processed statements. Semantic analysis and intent recognition are then performed on the processed statements to determine the target intent type (intent_type). Alternatively, a lightweight intent recognition model can be invoked, and the processed question-and-answer statements can be input into the intent recognition model to obtain the target intent type. The question-and-answer statement, Task_mode, and intent_type are passed to the dynamic workflow orchestration module via a preset transport protocol (such as Hypertext Transfer Protocol (HTTP) or Transmission Control Protocol / Internet Protocol (TCP / IP)). Then, the request receiving node in the dynamic workflow orchestration module sends the Task_mode to the conditional branch node.
[0052] S102: When the question-and-answer mode parameter is the first preset mode, determine the initial weight vectors corresponding to multiple preset search dimensions according to the target intent type corresponding to the question and answer statement; the multiple preset search dimensions include at least the document content dimension, the document metadata dimension, and the keyword dimension.
[0053] Here, the first preset mode can be the deep search mode. When the question-answering mode parameter is identified as a deep search value (e.g., {{ $json.task_mode===“deep search”}}), a deep search process involving adaptive hybrid search and answer generation will be initiated. Multiple preset search dimensions can include at least document content dimension, document metadata dimension, and keyword dimension. Among them, the keyword dimension can be the Best Matching 25 (BM25) keyword dimension.
[0054] Document data in the document content dimension is dimensional data formed by semantically vectorizing the document text. By converting the semantic content of the document into a high-dimensional vector representation, it performs semantic similarity matching with question and answer statements in a preset vector database, thereby achieving accurate response to the deep semantic intent of the question and answer statements.
[0055] Document data in the document metadata dimension is dimensional data formed by structured extraction and vectorization of document attribute information. Document attribute information may include, but is not limited to, file path, topic category, outline structure, version time, and document source. By converting attribute information into vector representations, the degree of matching between documents and question-and-answer statements at the attribute feature level can be evaluated during the retrieval process, thereby improving the accuracy and relevance of retrieval results. Introducing the document metadata dimension for content retrieval can overcome the limitations of existing technologies that rely on a single dimension of document content for retrieval. By incorporating document attribute features into the retrieval system and utilizing the correlation between metadata and question-and-answer statements, the discriminative ability during retrieval can be enhanced. For example, the benefits of document metadata-based retrieval can be seen in several aspects: it enables rapid filtering of document collections through structured information such as file paths and topic classifications, improving retrieval efficiency; it ensures the timeliness and authority of retrieval results by combining dynamic attributes such as version time, thereby further enhancing the accuracy and practicality of retrieval results based on semantic matching; and it establishes a quantitative assessment basis for document authority and credibility through source characteristics such as document source identifiers, thus prioritizing the selection of documents from authoritative sources and with reliable versions during the retrieval process, effectively improving the quality and credibility of retrieval results.
[0056] Document data at the keyword level consists of document keywords extracted from document content and / or document metadata. These keywords can be used for term matching between document content keywords and question-and-answer keywords. For example, algorithms such as BM25 can be used to calculate the matching degree between question-and-answer keywords and document content keywords, effectively capturing precise matching relationships of specific terms and proper nouns. This compensates for the shortcomings of semantic retrieval in handling technical terms and surface-level matching needs, thereby improving the recall and precision of search results.
[0057] The target intent type indicates the intent behind the question and answer statement. Examples include "fact lookup intent," "problem-solving intent," "step-by-step lookup intent," "concept explanation intent," and "comparative analysis intent." The target intent type can be obtained through semantic analysis of the question and answer statements and intent recognition based on the analysis results. Alternatively, it can be obtained by converting the question and answer statements into vector representations recognizable by intent recognition models (such as Text Convolutional Neural Network (TextCNN) or BERT models), and then inputting these vectors into the intent recognition model for deep semantic analysis and intent classification calculation, ultimately outputting the target intent type. Different intent types correspond to different query purposes; therefore, different intent types can correspond to different initial weight vectors. The initial weight vector indicates the importance of document data under a preset retrieval dimension. There is a preset correlation between intent types and initial weight vectors. By pre-establishing the correlation between different intent types and the initial weight vectors of each retrieval dimension, the initial weight vectors for the document content dimension, document metadata dimension, and keyword dimension can be quickly determined based on the target intent type, achieving automatic configuration of weight parameters based on query intent. For example, the association between the intent of "fact query" and the initial weight can be {document metadata: 0.6, document content: 0.2, BM25 keywords: 0.2}; the association between the intent of "step query" and the initial weight can be {document content: 0.5, BM25 keywords: 0.3, document metadata: 0.2}.
[0058] Optionally, to ensure the consistency of the weight scale, the initial weight vector of each retrieval dimension can take values in the range of [0, 1], and the sum of the initial weight vectors of each retrieval dimension is 1.
[0059] In practice, when the question-answering mode parameter is set to deep retrieval mode, semantic analysis and intent recognition can be performed on the question-answering statements to obtain the target intent type. Then, based on the correlation between the intent type and the initial weights, the initial weight vectors corresponding to the target intent type under multiple preset retrieval dimensions are determined.
[0060] Optionally, when using a question-and-answer system for question-and-answer processing, the conditional branch node in the dynamic workflow orchestration module, upon determining the question-and-answer mode parameter to be deep retrieval mode based on the Task_mode parameter passed by the interface service module, can determine the question-and-answer processing flow for the question-and-answer statement. For example, the conditional branch node can route the question-and-answer processing task flow to a "retrieval service call → result processing → generation service call" flow based on {{ $json.task_mode === "deep retrieval"}}. Then, following this question-and-answer processing flow, the retrieval service call node can be used to call the retrieval service module and send the target intent type and question-and-answer statement to the retrieval service module. Then, the retrieval service module can obtain the initial weight vectors corresponding to the target intent type in the three retrieval dimensions of document content, document metadata, and keywords based on the target intent type by querying pre-associations, thus completing the initial configuration of the weight parameters based on the query intent.
[0061] S103: Based on the question and answer keywords in the question and answer statements, adjust the initial weight vector corresponding to each preset search dimension to obtain the target weight vector corresponding to each preset search dimension.
[0062] Here, question-and-answer keywords refer to core terms with semantic distinctiveness extracted from user question-and-answer statements using natural language processing techniques. For example, they can be obtained through part-of-speech tagging and named entity recognition. Question-and-answer keywords are used to dynamically fine-tune the weights of each retrieval dimension based on the initial weight vector, thereby achieving precise optimization of the retrieval strategy based on query content features.
[0063] The target weight vector refers to the optimized weights obtained by dynamically fine-tuning the initial weight vector to form a weight allocation scheme that is highly consistent with the current question-answering needs, providing accurate weight parameters for multi-dimensional hybrid retrieval.
[0064] In practice, after extracting the keywords from the question-and-answer statements, the initial weight vectors for the document content dimension, document metadata dimension, and keyword dimension can be dynamically adjusted based on the number of keywords and the relevance of each keyword to the document content and document metadata, respectively, to obtain the target weight vectors for each preset retrieval dimension. For example, the initial weight vector for the keyword dimension can be adjusted upwards, downwards, or kept unchanged based on the number of keywords. The overall relevance between the question-and-answer statements and the "document content" can be determined based on the relevance between each keyword and the phrase "document content" (e.g., relevance calculated based on cosine similarity between semantics), and the initial weight vector for the document content dimension can be fine-tuned based on this overall relevance. Similarly, the overall relevance between the question-and-answer statements and the "document metadata" can be determined based on the relevance between each keyword and the phrase "document metadata," and the initial weight vector for the document metadata dimension can be fine-tuned based on this overall relevance. Optionally, question-and-answer keywords can be input into a pre-trained relevance discrimination model (such as a Transformer-based Cross-Encoder Architecture Model, or Cross-Encoder) to obtain relevance scores for each preset retrieval dimension. These relevance scores are then used to weight the initial weight vectors, ultimately generating optimized target weight vectors. Understandably, to ensure weight scaling, the sum of the weights for each preset retrieval dimension being equal to 1 can be used as a constraint for fine-tuning the weights when dynamically adjusting the initial weight vectors.
[0065] Optionally, when using a question-and-answer system for question-and-answer processing, the dynamic weight calculation unit in the retrieval service module can be used to dynamically fine-tune the initial weight vector under each preset retrieval dimension based on the number of question-and-answer keywords and the relevance between each question-and-answer keyword and the document content and document metadata.
[0066] S104: Based on the target weight vector and the document data of each document to be matched under each preset search dimension, determine multiple target document fragments that match the question and answer statement.
[0067] First, it should be noted that there is no strict execution order between S103 and S104 in this embodiment. They can be executed synchronously or asynchronously, and the execution order can be any order when executing asynchronously. In actual implementation, one can either perform dynamic optimization of the weight vector based on question-and-answer keywords first, as described in the embodiments of this application, and then perform hybrid retrieval, or perform multi-dimensional parallel retrieval first and then dynamically adjust the weight configuration based on the retrieval results. Alternatively, the weight configuration can be dynamically adjusted while performing multi-dimensional parallel retrieval. All implementation orders can achieve the technical objective of adaptively optimizing the retrieval effect based on the user's question-and-answer intent.
[0068] The document to be matched can be a document stored in any authorized external database. It can be a complete document or a document fragment obtained by segmenting a complete document. Document data can be preprocessed and stored data of the document to be matched, thus providing a computable data foundation for multi-dimensional hybrid retrieval. Preprocessing includes feature extraction and vectorization of the document content and metadata, as well as keyword extraction from the document content. Therefore, the document data of the document to be matched can include, but is not limited to, document content vectors, document metadata vectors, and document keywords. For example, the document content and document metadata can be vectorized and stored in a pre-defined vector database. Keyword extraction technology is used to extract keywords from the document content to obtain document keywords. These document keywords can be vectorized and stored in the pre-defined vector database, or they can be directly stored in a pre-defined thesaurus.
[0069] The target document fragments are the individual document fragments found from the documents to be matched after a multi-dimensional hybrid retrieval. These documents can be used to form the input of a large language model to generate response results.
[0070] In practice, question-and-answer vectors corresponding to the question-and-answer statements can be generated. The content matching result of the question-and-answer statements in the document content dimension is determined based on the vector similarity between the question-and-answer vectors and the document content vectors of each document to be matched. The metadata matching result of the question-and-answer statements in the document metadata dimension is determined based on the vector similarity between the question-and-answer vectors and the document metadata vectors of each document to be matched. The keyword matching result of the question-and-answer statements in the keyword dimension is determined based on the BM25 keyword matching degree between the question-and-answer keywords and the document keywords of each document to be matched. Using the target weight vectors of each preset retrieval dimension, the matching results in each preset retrieval dimension are weighted and summed to obtain the target matching degree between the question-and-answer statements and each document to be matched. Based on the target matching degree, multiple target document fragments are selected from the documents to be matched. For example, the N document fragments with the highest target matching degree can be selected as target document fragments. The number of N can be set empirically or determined based on the processing capacity of a large language model. Alternatively, the value of N can be determined based on the distribution of the target matching degree, and then the N document fragments with the highest target matching degree can be selected as target document fragments.
[0071] Optionally, when using a question-answering system for question-answering processing, a retrieval service module can be used to perform multi-dimensional hybrid retrieval based on question-answering vectors, question-answering keywords, document content vectors of each document to be matched, document metadata vectors, and document keywords to obtain target document fragments. For example, based on question-answering vectors, similarity searches are performed on the vectorized document content vectors and document metadata vectors respectively, and BM25 keyword matching is performed by combining question-answering keywords and document keywords; based on the target weight vectors of each preset retrieval dimension, and based on the similarity search results and BM25 keyword matching results, the target matching degree between the question-answering statements and each document to be matched is determined. Based on the target matching degree, multiple target document fragments are selected from the documents to be matched.
[0072] S105: Utilize a large language model to generate answer results that match the question-and-answer request based on multiple target document fragments.
[0073] Here, a large language model (LLM) can be a general neural network model obtained by pre-training on massive amounts of text data. It has powerful text generation, semantic understanding and logical reasoning capabilities, and can automatically generate text content that conforms to language norms and semantic coherence based on the input context information.
[0074] When generating responses using a large language model, two response modes are available: streaming and non-streaming. Streaming mode outputs the response word-by-word, while non-streaming mode outputs the entire response directly. Optionally, users can also choose between streaming and non-streaming modes when visualizing the response. Streaming mode displays the generated response word-by-word, while non-streaming mode displays the completed response directly to the user when the large language model outputs it. This dual-mode response mechanism can be controlled via interface parameters, allowing the question-and-answer process to adaptively adjust data transmission strategies based on users' real-time requirements, balancing immediate interactive experience with data integrity.
[0075] In practice, multiple target document fragments and question-and-answer statements can be integrated into a format supported by LLM. The integrated target document fragments and question-and-answer statements are then concatenated with multiple preset prompts to obtain the target prompts. These target prompts are then input into the LLM model for processing, resulting in the LLM-generated answer, which is then displayed to the user.
[0076] Optionally, the document source information of each target document fragment can be concatenated into target prompts and input into the LLM, allowing the LLM to generate more accurate document results based on the complete document information from the source. Understandably, after obtaining the answer, the answer along with its related document source information can also be displayed to the user.
[0077] Optionally, to further reduce the processing pressure on the LLM model, the target document fragments and question-and-answer statements after format integration can be compressed first, and the compressed content can be concatenated with multiple preset prompts to obtain the target prompts.
[0078] Optionally, when using a question-answering system for question-answering processing, a generation service call node can be used to invoke the generation service module. This module receives formatted data from the workflow engine (including target document fragments, user requests, and document source information for the target document fragments), and constructs a complete prompt containing question-answering instructions, retrieval context, and user questions. For example: "Please answer the question based on the following background information: [target document fragment], [document source information], question: [question-answer statement]". The prompt is then input into the LLM in the generation service module to generate an answer. To further improve the accuracy of the LLM generation results, a model temperature parameter can be preset for the LLM under different question-answering mode parameters. Before inputting the prompt into the LLM in the generation service module, the relevant parameters of the LLM can be configured according to the question-answering mode parameters, so that the LLM model can generate answer results based on the configured parameters. For example, in the "deep retrieval" mode, a temperature of 0.3 is set to reduce the creativity of the LLM and improve factual accuracy; in the "quick question-answering" mode, a temperature of 0.7 is set to improve the universality and fluency of the answer. Furthermore, after the LLM model outputs its answer, the first result processing node set in the dynamic workflow orchestration module can be used to call the interface service module to further post-process the answer output by the large language model, so as to obtain the final processed answer and display it to the user. This post-processing may include, but is not limited to: first, encapsulating the raw text returned by the model into a predefined, uniformly formatted data structure (such as a standardized JSON response body) to ensure the standardization of front-end and back-end data interaction; then, automatically extracting the source information of the referenced target document fragments (including but not limited to document name, chapter number, and page number) and embedding it as an annotation in the answer; simultaneously, performing secondary filtering of sensitive words and format optimization on the output text, finally generating a complete answer containing structured content, traceable source, and conforming to security standards, which is returned to the user.
[0079] In this way, existing large language models can generate answers based on high-quality, credible target document fragments, rather than relying solely on their own potentially outdated or inaccurate knowledge. This alleviates the "illusion" problem in the answering process of existing technologies and ensures the accuracy and factuality of the answers.
[0080] In one embodiment, following step S101, the following steps can be taken:
[0081] When the question-and-answer mode parameter is the second preset mode, a large language model is used to generate an answer that matches the question-and-answer request based on the question-and-answer statement; the first preset mode and the second preset mode correspond to different question-and-answer processing flows.
[0082] Here, the second preset mode can be the quick question and answer mode. When the question and answer mode parameter is identified as a quick question and answer value (e.g., {{ $json.task_mode===“Quick Question and Answer”}}), the retrieval process can be skipped and the answer generation process can be started directly.
[0083] The question-and-answer processing flow is the process of processing question-and-answer requests and generating results. In this embodiment, the question-and-answer processing flow corresponding to the first preset mode can be "question-and-answer request → determination of initial weight vector and target weight vector → retrieval service call → result processing → generation of service call" flow, and the question-and-answer processing flow corresponding to the second preset mode can be "question-and-answer request → generation of service call" flow.
[0084] In practical implementation, when the question-and-answer mode parameter is set to quick question-and-answer mode, it indicates that the user has a need to quickly obtain the answer result. To improve the answer speed, the question-and-answer statement or request can be directly input into the LLM model. Alternatively, the question-and-answer statement or request, along with a blank context or preset general prompt information, can be input into the LLM model. The LLM model then uses the learned knowledge to generate and output the answer result.
[0085] Optionally, when using a question-and-answer system for question-and-answer processing, the conditional branch node in the dynamic workflow orchestration module, upon determining the question-and-answer mode parameter to be "fast question-and-answer" based on the Task_mode parameter passed by the interface service module, can determine the question-and-answer processing flow for the question-and-answer statement. For example, the conditional branch node can directly route the question-and-answer processing task flow to the question-and-answer processing flow of the "generation service" based on {{ $json.task_mode === "fast question-and-answer"}}. Then, following this question-and-answer processing flow, the generation service call node calls the generation service module. Using the LLM in the generation service module, an answer matching the user's question-and-answer request is generated. The interface service module then further processes the answer output from the large language model, ultimately generating a complete and standardized answer and returning it to the user, thereby optimizing resource utilization and response speed.
[0086] In one embodiment, S103 described above can be implemented according to the following steps A1 to A4:
[0087] A1: Obtain the target keyword library corresponding to each preset search dimension; the target keyword library includes the document content keyword library, the document metadata keyword library, and the keyword library based on statistical features.
[0088] Here, the target keyword library can be a pre-built keyword library that supports real-time updates. Each preset search dimension corresponds to a target keyword library, and each target keyword library differs from the vector database and preset thesaurus mentioned above. Specifically, the target keyword library can include a document content keyword library corresponding to the document content dimension, a document metadata keyword library corresponding to the document metadata dimension, and a keyword library based on statistical features corresponding to the keyword dimension. These statistical features may include, but are not limited to, word frequency, part-of-speech tagging, word popularity, inverse document frequency, and document length. Each keyword in the target keyword library under each preset search dimension can be a commonly used and important keyword obtained by knowledge extraction from various information under that preset search dimension.
[0089] The document content keyword database is a pre-built collection of domain-specific terms. It is constructed by collecting core terms and high-frequency concepts from professional documents and is used to calculate the matching degree with keywords in user queries during the weight adjustment phase. For example, in the medical field, the document content keyword database may contain professional terms such as "platelet count" and "XX test". When these specific words are detected in a query, the system will automatically increase the retrieval weight of the document content dimension, thereby achieving accurate weight allocation based on domain knowledge.
[0090] The document metadata keyword library is a pre-configured set of document attribute feature words. It is constructed by extracting and integrating document metadata such as file paths, document types, and version identifiers of different documents. It is used to identify key terms related to document attributes in user queries during the dynamic weight adjustment phase. For example, when the query contains path fragments such as " / financial report / Q4 / 2023" or document type keywords such as "technical white paper", the system will increase the retrieval weight of the metadata dimension based on the matching results of the keyword library, thereby achieving accurate retrieval optimization based on document attribute features.
[0091] A keyword database based on statistical features is a set of core terms extracted from a document collection using a pre-defined keyword algorithm (such as the BM25 algorithm) based on the statistical features of different documents. It filters out highly discriminative terms by calculating word frequency distribution and document frequency, and uses these terms to identify key matching terms in user queries during the dynamic weight adjustment phase. For example, when a query contains high-frequency cross-domain terms such as "implementation plan" or "performance indicators," the system will increase the retrieval weight of the keyword dimension based on the database matching results, thereby optimizing the retrieval matching accuracy for general terms.
[0092] For ease of description, the following description will use a question-and-answer system for question-and-answer processing as an example. However, in specific implementation, the embodiments of this application can also use a server with integrated functions to implement question-and-answer processing, and the process of the server performing question-and-answer processing is similar to that of using a question-and-answer system.
[0093] Taking the use of the retrieval service module as an example, during implementation, the retrieval service module can call the document content keyword library, the document metadata keyword library, and the keyword library based on statistical features through the calling interface of each target keyword library, thereby integrating multi-dimensional keyword resources for use when dynamically adjusting weights.
[0094] A2: Determine the keywords in the question and answer statements and their matching results with each target keyword database; the matching results include the number of keyword matches and / or the matched keywords.
[0095] Here, question-and-answer keywords are core terms with semantic representation capabilities extracted from user request statements using natural language processing technology. They can be obtained through part-of-speech tagging and named entity recognition technologies and used for matching calculations with various target keyword libraries.
[0096] In practice, the dynamic weight calculation unit in the retrieval service module can be used to extract question-and-answer keywords from user question-and-answer statements. Then, using these keywords, keyword matching is performed on each target keyword library to obtain matching results corresponding to each target keyword. For example, from the question-and-answer statement "Application of multi-head self-attention mechanism in BERT model," keywords such as "multi-head self-attention," "BERT model," and "application" can be extracted. These keywords are then matched in parallel with keywords in the document content keyword library (such as "self-attention," "Transformer," etc.), the metadata keyword library (such as "technical white paper," "V2.0," etc.), and the statistical feature-based keyword library (such as "mechanism," "model," etc.). Finally, the number of matches for each target keyword library (e.g., 3 matches for document content keywords, 1 match for document metadata keywords, and 1 match for statistical feature-based keywords) and a list of specific matched keywords are output, providing a quantitative basis for subsequent dynamic weight adjustments.
[0097] A3: Perform intent analysis on the question and answer statements to determine the intent probability of the question and answer statements under various preset intent types; preset intent types include target intent types.
[0098] Here, the preset intent type is a predefined set of standard user question-and-answer request intent categories. The number of preset intent types is not specifically limited in this embodiment and can be determined based on various intents that may arise during the question-and-answer process. The preset intent type may include the target intent type and multiple other intent types. For example, preset intent types may include "fact query intent," "problem-solving intent," "step-by-step query intent," "concept explanation intent," "comparative analysis intent," etc. The intent probability is used to indicate the probability that a preset intent type exists in the question-and-answer statement.
[0099] In practice, the retrieval service module can be used to call a lightweight intent analysis model (such as a lightweight BERT classification model) to perform real-time intent analysis on the question-and-answer statements, obtaining the intent probabilities corresponding to the question-and-answer statements under various preset intent types. For example, when a user inputs "compare the advantages and disadvantages of RNN and LSTM in time series prediction," the lightweight intent analysis model can simultaneously calculate the probability distribution of the statement under preset intent types such as "comparative analysis," "concept explanation," and "fact query," outputting the intent probability distribution of {"comparative analysis": 0.76, "concept explanation": 0.18, "fact query": 0.06}. This probability distribution will be used as the feature input for subsequent dynamic weight fine-tuning.
[0100] A4: Based on the matching results, intent probability, and text length of the question and answer statements corresponding to each target keyword library, the initial weight vectors corresponding to each preset search dimension are adjusted to obtain the target weight vector.
[0101] Here, the text length of the question and answer statements is used to indicate the amount of text in the question and answer statements. A preset text length threshold (such as 15 characters) is used as a criterion for judging the text length in order to identify the complexity of the question and answer during the weight adjustment process.
[0102] In practice, a dynamic weight calculation unit can be used to determine the adjustment range of the initial weight vector corresponding to each preset search dimension based on the matching results of each target keyword library, the probability distribution of intent, and the relationship between the text length and the preset text length threshold. Then, the initial weight vectors are dynamically adjusted according to the adjustment range to obtain the target weight vectors corresponding to each preset search dimension.
[0103] For example, dynamic weight adjustment can be achieved through the following process: When the received question-and-answer statement is "Specific application scenarios of multi-head self-attention mechanism in natural language processing and its performance comparison with recurrent neural networks", it is found that the number of matching statements in the document content keyword library is 4, the number of matching statements in the metadata keyword library is 2, and the number of matching statements in the keyword library based on statistical features is 1. At the same time, the intent probability distribution output by the lightweight BERT model is {"Comparative analysis": 0.7, "Concept explanation": 0.25}, and the text length (28 characters) is detected to exceed the preset text length threshold (e.g., 20 characters). Based on these features, the initial weight vectors corresponding to the document content dimension, document metadata dimension, and keyword dimension are adjusted according to the preset adjustment rules to obtain the adjusted target weight vector.
[0104] In one embodiment, for A4 above, it can be implemented according to the following steps B1 to B4:
[0105] B1: Based on the matching results of each target keyword database, determine the first adjustment strategy under each preset search dimension.
[0106] Here, the first adjustment strategy is used to indicate the first adjustment magnitude of the initial weight vector under each preset search dimension. The first adjustment magnitude can be increasing the target value, decreasing the target value, or keeping it unchanged, etc.
[0107] For example, a dynamic weight calculation unit can be used to determine the first adjustment strategy for each preset search dimension based on the distribution of matching quantities under each target keyword library and / or the distribution of the number of preset target keywords included in the matching keywords under each target keyword library. For instance, when the number of matching quantities between question-and-answer keywords and document content keywords is detected to be the highest, the initial weight vector value corresponding to the document content dimension can be increased by a preset adjustment margin (e.g., 0.05-0.1), while the initial weight vector values corresponding to the document metadata dimension and keyword dimension are decreased accordingly. When the number of matching keywords between question-and-answer keywords and document metadata keywords is detected to include preset target keywords, the initial weight vector value corresponding to the document metadata dimension can be increased, while the initial weight vector values corresponding to the document content dimension and keyword dimension are decreased accordingly.
[0108] Optionally, when determining the adjustment range under each preset search dimension, in order to ensure that the weights of each dimension meet the constraints (such as the sum of all weights being always 1), a compensation adjustment mechanism can be adopted. When a certain dimension increases by a predetermined amount, the other dimensions share the corresponding reduction proportionally. Alternatively, a normalization method can be adopted to proportionally scale the adjustment range corresponding to each preset search dimension to obtain the normalized adjustment range of each preset search dimension.
[0109] B2: Determine the second adjustment strategy for each preset retrieval dimension based on the probability of each intent.
[0110] Here, the second adjustment strategy is used to indicate the second adjustment magnitude of the initial weight vector under each preset retrieval dimension. The second adjustment strategy is a weight adjustment strategy preset based on the intent probability distribution.
[0111] In specific implementation, a dynamic weight calculation unit can be used to determine a second adjustment strategy for the initial weight vector under each preset search dimension based on the intent probability under each preset intent type and the most relevant preset search dimension under each preset intent type. Alternatively, the weight coefficients for each preset intent type under each preset search dimension can be determined based on the intent probability under each preset intent type. Then, for each preset intent type, a first weight vector for that preset intent type under each preset search dimension can be determined based on the correlation between the intent type and the weight vector mentioned above. The second weight vector for that preset intent type under each preset search dimension is obtained by multiplying the weight coefficient corresponding to that preset intent type by the first weight vector under the corresponding search dimension. Based on the second weight vectors for each preset intent type under each preset search dimension, the adjustment range of the initial weight vector under each preset search dimension is determined. Alternatively, the top X preset intent types with the highest intent probabilities can be determined based on the intent probability under each preset intent type. The value of X can be set empirically, and this embodiment does not impose specific limitations. Then, using the intent probabilities under the first X preset intent types, the adjustment range corresponding to the most relevant preset search dimensions for the first X preset intent types is determined, and these adjustment ranges are used as the second adjustment range under each preset search dimension.
[0112] For example, when a question-and-answer statement has a high probability of 0.8 or higher for the intent of "fact query", the initial weight vector values corresponding to the document metadata dimension and document content dimension can be increased by a preset adjustment range, while the initial weight vector values corresponding to the keyword dimension can be reduced accordingly. This adapts to the strong dependence on document source and timeliness features under this intent type, and achieves accurate weight adaptation based on intent probability features.
[0113] B3: Determine the third adjustment strategy under each preset search dimension based on the text length of the question and answer statements.
[0114] Here, the third adjustment strategy is used to indicate the third adjustment magnitude of the initial weight vector under each preset search dimension.
[0115] In practical implementation, a dynamic weight calculation unit can be used to determine whether the text length of the question-and-answer statement exceeds a preset text length threshold. If so, the third adjustment magnitude of the initial weight vector under each preset search dimension can be determined based on the adjustment magnitude of each preset search dimension indicated by the first preset adjustment rule. The first preset adjustment rule indicates the preset adjustment magnitude corresponding to each preset search dimension when the document length exceeds the threshold. Alternatively, if so, the third adjustment magnitude of the initial weight vector under each preset search dimension can also be determined based on the extent to which the text length exceeds the preset text length threshold and the adjustment magnitudes of each preset search dimension corresponding to different extent ranges of exceedance indicated by the second preset adjustment rule. If not, the third adjustment magnitude of the initial weight vector under each preset search dimension can be determined to be 0, i.e., the initial weight vector under each preset search dimension is maintained.
[0116] For example, if the text length exceeds a preset text length threshold, the initial weight vector value under the document content dimension can be increased (e.g., increased by 0.05) according to the preset adjustment range indicated by the first preset adjustment rule, and the initial weight vector values under the corresponding document metadata dimension and keyword dimension can be reduced accordingly. This adapts to the dependence of long text queries on deep semantic understanding and realizes adaptive weight configuration based on question-answering complexity.
[0117] B4: Adjust the initial weight vectors corresponding to each preset search dimension according to at least one of the first adjustment strategy, the second adjustment strategy, and the third adjustment strategy to obtain the target weight vector.
[0118] In practice, when selecting any one of the first, second, and third adjustment strategies, the dynamic weight calculation unit can be used to adjust the initial weight vectors corresponding to each preset search dimension based on the adjustment range indicated by the selected adjustment strategy, so as to obtain the target weight vectors for each preset search dimension.
[0119] When selecting any two or three of the first, second, and third adjustment strategies, a dynamic weight calculation unit can be used to determine the target adjustment magnitude for each preset search dimension based on the mean, variance, and extreme values of the adjustment magnitude indicated by each adjustment strategy on each preset search dimension. Then, the initial weight vectors corresponding to each preset search dimension are adjusted according to the target adjustment magnitude to obtain the target weight vector for each preset search dimension. Alternatively, the preset weight coefficients corresponding to the selected adjustment strategy can be used to multiply the adjustment magnitudes indicated by the selected adjustment strategy to obtain the intermediate adjustment magnitudes corresponding to the selected adjustment strategy under various preset search dimensions. Then, based on the mean, variance, and extreme values of the intermediate adjustment magnitudes of each selected adjustment strategy on each preset search dimension, the target adjustment magnitude for each preset search dimension is determined. Finally, the initial weight vectors corresponding to each preset search dimension are adjusted according to the target adjustment magnitude. The preset weight coefficients can be predetermined based on the importance of matching results, intent probability, and text length to the search results. Alternatively, based on the adjustment range indicated by each selected adjustment strategy on each preset search dimension, the maximum and minimum adjustment ranges corresponding to each preset search dimension can be determined (for example, when all three adjustment strategies are selected, the maximum and minimum adjustment ranges for the document content dimension can be determined based on the first to third adjustment ranges corresponding to the three adjustment strategies respectively; the determination process for the document metadata dimension and keyword dimension is similar and will not be elaborated further). Then, for each preset search dimension, the target adjustment range for that preset search dimension is determined based on the difference between the maximum and minimum adjustment ranges corresponding to that preset search dimension. For example, if the difference between the maximum and minimum adjustment ranges is greater than a preset difference, the target adjustment range can be determined as a smaller preset adjustment range or the average of the maximum and minimum adjustment ranges, thereby ensuring that corresponding search results can be retrieved for each search dimension; if the difference between the maximum and minimum adjustment ranges is not greater than a preset difference, it indicates that all adjustment methods indicate the need for a similar adjustment range for that dimension, and the maximum adjustment range can be used as the target adjustment range. Finally, the initial weight vectors corresponding to each preset search dimension can be adjusted according to the target adjustment range to obtain each target weight vector.
[0120] For example, a dynamic weight calculation unit can be used to adjust the initial weight vectors corresponding to each preset retrieval dimension simultaneously according to a first adjustment strategy, a second adjustment strategy, and a third adjustment strategy to obtain the target weight vector. For instance, when the question-and-answer statement is "The core technical principles of the Transformer model in machine translation and its differences from RNNs," if the first adjustment strategy indicates that the initial weight vector value corresponding to the document content dimension needs to be increased by 0.07, the initial weight vector value corresponding to the document metadata dimension needs to be increased by 0.02, and the initial weight vector value corresponding to the keyword dimension needs to be decreased by 0.09; the second adjustment strategy indicates that the initial weight vector value corresponding to the document content dimension needs to be increased by 0.05, the initial weight vector value corresponding to the document metadata dimension needs to be decreased by 0.08, and the initial weight vector value corresponding to the keyword dimension needs to be increased by 0.03; and the third adjustment strategy indicates that the initial weight vector value corresponding to the document content dimension needs to be increased by 0.06, the initial weight vector value corresponding to the document metadata dimension needs to be decreased by 0.01, and the initial weight vector value corresponding to the keyword dimension needs to be decreased by 0.01. If the initial weight vector value corresponding to a dimension needs to be reduced by 0.05, the range arbitration algorithm can be used. That is, the range of the three adjustment values (0.07, 0.05, 0.06) for the document content dimension is calculated to be 0.02 (the difference is small). Therefore, the extreme value of 0.07 is taken as the target adjustment range of the initial weight vector value corresponding to the document content dimension. For the document metadata dimension, due to policy conflicts (the first adjustment strategy indicates an increase of 0.02, the second adjustment strategy indicates a decrease of 0.08, and the third adjustment strategy indicates a decrease of 0.01), the weighted average is taken to obtain the target adjustment range of 0.035. For the keyword dimension, due to policy conflicts, the target adjustment range can be reduced by 0.055. Finally, after normalization, the target weight vector is obtained [content: 0.58, metadata: 0.22, keywords: 0.20].
[0121] Optionally, if the initial weight vector under a preset search dimension is adjusted using the target adjustment range, and the adjusted weight vector is less than 0, the target weight vector under the preset search dimension can be set to the default value.
[0122] In one embodiment, S104 described above can be implemented according to the following steps C1 to C4:
[0123] C1: Based on the document content vectors of each document fragment in the document content dimension of each document to be matched in the preset vector database, and the question and answer vectors corresponding to the question and answer statements, determine the first similarity between the question and answer statements and each document fragment.
[0124] Here, the preset vector database is a pre-built dedicated database used to store all document vectorized representations (such as document content vectors and document metadata vectors).
[0125] Document content vectors can be obtained by converting the text content of each document fragment into a fixed-dimensional vector representation using a pre-trained language model (such as Sentence-BERT, a sentence-level bidirectional encoder representation model). The fixed dimensions can be, for example, 32, 64, 128, 512, or 768 dimensions.
[0126] If the document to be matched is a complete document, then the document fragment of the document to be matched can be obtained by splitting the complete document into paragraphs; if the document to be matched is itself a document fragment, then the document fragment of the document to be matched is the document to be matched itself.
[0127] Question-answer vectors can be fixed-dimensional vector representations obtained by embedding words into question-answer statements using a pre-trained language model. The first similarity score is used to characterize the content similarity between the question-answer statements and the document fragments.
[0128] In practice, the retrieval service module can be used to call a pre-trained language model to encode the question-and-answer statements into question-and-answer vectors. Then, the document content vectors of each document fragment stored in the preset vector database are calculated, and the vector similarity (such as cosine similarity) between them and the question-and-answer vectors is calculated. This vector similarity is used as the first similarity between the question-and-answer statements and the corresponding document fragments.
[0129] C2: Based on the document metadata vector of each document fragment in the preset vector database under the document metadata dimension, and the question and answer vector corresponding to the question and answer statement, determine the second similarity between the question and answer statement and each document fragment; the document metadata vector includes at least the file path vector, topic classification vector, outline structure vector, version time vector, and document source vector.
[0130] Here, document metadata vectors can be high-dimensional vector numerical representations of various document metadata (such as file paths, topic categories, outline structures, version times, and document sources), used to evaluate the degree of matching between document attribute features and query intent during the retrieval process. File paths can be used to indicate information such as document names and storage paths. Topic categories are used to indicate the type of document fragment, such as equipment maintenance manuals, operating procedures, and popular science content.
[0131] For example, when the document path is "Technical White Paper / Artificial Intelligence / Neural Network / V2.1 / Chinese Academy of Sciences / XXX", the path can be split into hierarchical vectors. For instance, the topic "Artificial Intelligence" can be encoded as a semantic vector, the version "V2.1" can be converted into a time vector, and the source "Chinese Academy of Sciences" can be encoded as an authority vector. Together, these form a metadata vector to accurately match question and answer requirements that include the attribute "latest authoritative technical document".
[0132] Specifically, the retrieval service module can include a multi-dimensional vector generation unit. Before question-and-answer processing, the multi-dimensional vector generation unit in the retrieval service module can be used to construct and store document content vectors and document metadata vectors in the following ways:
[0133] A pre-trained language model is used to convert the document content of each document fragment into 768-dimensional semantic vectors, forming document content vectors for each document fragment. These vectors are stored in a pre-defined vector database of document content vectors (DocumentContentVectors, doc_content_vectors). Simultaneously, the pre-trained language model can be used to vectorize various document metadata of each document fragment, obtaining document metadata vectors with the same dimensions as the document content vectors. These metadata vectors are also stored in the pre-defined vector database of document metadata vectors (Document MetadataVectors, doc_metadata_vectors). Furthermore, document content vectors and document metadata vectors of the same document fragment can be linked and indexed using a unique document identifier (Document Identifier, doc_id). For example, during the generation of document metadata vectors, file paths can be hierarchically split and word embeddings can be performed, topic tags can be directly embedded, outline structures can be converted into hierarchical vectors, version times can be mapped into time-series vectors, and document sources can be authoritatively encoded and converted into document source vectors, thus obtaining various document metadata vectors.
[0134] The second similarity metric characterizes the similarity between the question-and-answer statements and the metadata of the document fragments. It can be used to assess the degree of matching between user questions and answers and document attribute features. By calculating the similarity between the question-and-answer vectors and metadata features such as the version time vector and document source vector of each document fragment, document fragments with the highest matching degree in terms of version timeliness and source authority can be selected, thereby improving the quality and reliability of search results.
[0135] In practical implementation, the retrieval service module can be used to calculate the vector similarity (e.g., cosine similarity) between each document metadata vector stored in a pre-defined vector database and the question-and-answer vector for each document fragment. Then, based on the vector similarity corresponding to each document metadata vector, a second similarity between the question-and-answer statement and the document fragment can be determined. For example, the second similarity can be determined based on the mean of the vector similarities corresponding to each document metadata vector. Optionally, since different types of document metadata may have different confidence levels, to further improve the accuracy of the determined second similarity, for any document fragment, after calculating the vector similarity corresponding to each document metadata vector, the vector similarity corresponding to each document metadata vector can be weighted based on the confidence weight corresponding to each type of document metadata vector to obtain the second similarity between the question-and-answer statement and the document fragment. The confidence levels of each document metadata for various document fragments can be obtained from a pre-trained language model or by using other pre-trained confidence models.
[0136] For example, for any document fragment, the version time vector has a confidence score of 0.9, the document source vector has a confidence score of 0.8, etc. When the similarity between the question-answer vector and the document's version time vector reaches 0.9 (confidence score 0.9), and the similarity with the document source vector reaches 0.8 (confidence score 0.8), after weighted calculation and normalization, a second similarity score of 0.725 is obtained. This confidence weighting mechanism effectively ensures the accuracy and reliability of metadata retrieval results.
[0137] C3: Based on the question-and-answer keywords in the question-and-answer statement and the document keywords in the document fragments of each document to be matched, determine the third similarity between the question-and-answer statement and each document fragment.
[0138] Here, document keywords can be core terms with semantic representation capabilities extracted from document fragments using natural language processing techniques. The third similarity is used to characterize the keyword similarity between the question-and-answer statement and the document fragments; it quantifies the degree of matching between the question-and-answer statement and each document fragment at the term level.
[0139] In practical implementation, the retrieval service module can be used to calculate the matching degree between each question-and-answer keyword and each document keyword in the document fragment using the BM25 algorithm for any document fragment. By statistically analyzing features such as keyword frequency, distribution density, and inverse document frequency in the document, a numerical third similarity is ultimately generated. For example, when processing technical documents containing keywords such as "convolutional neural network," "vanishing gradient," and "activation function," the BM25 algorithm can calculate a third similarity of 0.75 between the document fragment and the question-and-answer statements, effectively supplementing the shortcomings of semantic retrieval in precise matching of technical terms.
[0140] C4: Based on the target weight vector, first similarity, second similarity, and third similarity, select multiple target document fragments from the document fragments of each document to be matched.
[0141] In practical implementation, the retrieval service module can be used to calculate the product of the target weight vector and the first similarity score under the document content dimension, the product of the target weight vector and the second similarity score under the document metadata dimension, and the product of the target weight vector and the third similarity score under the keyword dimension for each document fragment. The sum of these three products is used as the target similarity between the question / answer statement and the document fragment. Based on the target similarity scores of each document fragment, multiple target document fragments are selected from the document fragments of each document to be matched. For example, the document fragments can be sorted in descending order of target similarity, and the document fragments with a sort order lower than a preset order can be used as target document fragments. Alternatively, document fragments with a target similarity score greater than a preset similarity threshold can be used as target document fragments.
[0142] In one embodiment, C4 described above can be implemented according to the following steps D1 to D3:
[0143] D1: For any document fragment, use the target weight vectors under each preset retrieval dimension to weight the first similarity, second similarity and third similarity of the document fragment to obtain the first target similarity of the document fragment.
[0144] Here, the first objective similarity is used to characterize the comprehensive similarity between document fragments and question-and-answer statements under dimensionality trade-offs.
[0145] In practice, for any document fragment (such as a technical document fragment about "deep residual network connectivity"), the retrieval service module can be used to perform a weighted sum of the similarities of the document fragment under the corresponding preset retrieval dimensions (e.g., [document content: 0.6, document metadata: 0.25, keywords: 0.15]) under the corresponding preset retrieval dimensions (the first similarity for the document content dimension is 0.82, the second similarity for the document metadata dimension is 0.75, and the third similarity for the keyword dimension is 0.88). The first target similarity between the document fragment and the question and answer statement is 0.6×0.82+0.25×0.75+0.15×0.88=0.8145. For example, when processing a medical document fragment, the semantic similarity of 0.8, metadata matching degree of 0.7, and keyword matching degree of 0.9 are weighted according to the target weight vector [0.5, 0.3, 0.2] to obtain the first target similarity of 0.8×0.5+0.7×0.3+0.9×0.2=0.79.
[0146] D2: Based on the first target similarity, select multiple first candidate document fragments from the document fragments. Determine the importance score of each first candidate document fragment based on its importance.
[0147] Here, the first candidate document fragments are the document fragments obtained from the initial retrieval, which serve as a preliminary result set for subsequent refined retrieval. The number of first candidate document fragments is greater than the number of target document fragments.
[0148] The importance of each first-choice document fragment is determined based on its structural position and logical relationship within the source document, and is used to increase the weight of fragments with important structural features during the re-ranking stage. Structural positions include, but are not limited to, titles, abstracts, introductions, chapter opening paragraphs, conclusions, appendices, references, footnotes, and body paragraphs. Titles, abstracts, introductions, chapter opening paragraphs, and conclusions typically contain the most valuable core viewpoints and summaries, thus having high importance. Body paragraphs have moderate importance. Appendices, references, and footnotes typically contain less valuable supplementary content, thus having lower importance. Logical relationships include, but are not limited to, conceptual definition relationships, argument support relationships, technological evolution relationships, functional description relationships, and causal relationships. Conceptual definition relationships determine whether each first-candidate document fragment contains the first definition or authoritative explanation of core terms. Argument support relationships determine whether each first-candidate document fragment occupies a position in the logical argument chain as a statement of arguments, supporting evidence, or a summary of conclusions. Technological evolution relationships determine whether each first-candidate document fragment in the technical document embodies a logical progression of principle explanation, implementation method, and advantages and disadvantages analysis. Functional description relationships determine whether each first-candidate document fragment includes systematic descriptions such as functional module descriptions, interface definitions, and parameter configurations. Causal relationships determine whether each first-candidate document fragment contains continuous paragraphs with logical causal relationships, such as principle derivation, experimental verification, and result analysis.
[0149] Importance scoring is a quantitative value assigned to each first-candidate document fragment based on its structural position and logical relationship within the original text. This value is used to calibrate the weighting of first-candidate document fragments during the re-ranking stage. For example, when a first-candidate document fragment is located in a core section of the original technical document (title, abstract, introduction, first paragraph, conclusion), it can be assigned an importance score of 0.3 based on its structural features that carry the main technical solutions. In contrast, a first-candidate document fragment located in an appendix supplementary section is assigned only a score of 0.1. This mechanism ensures that the final output target document fragments possess both semantic relevance and knowledge authority.
[0150] By introducing importance scoring, we can avoid using a minor segment in the appendix that was matched only because the keyword appeared multiple times as a reference for the main answer, thereby significantly improving the accuracy and reliability of the answer.
[0151] In practical implementation, the retrieval service module can be used to filter out candidate document fragments from all document fragments based on the first target similarity. For example, it can filter out candidate document fragments whose first target similarity is greater than a preset similarity. Alternatively, it can filter out a preset number of candidate document fragments based on a preset number and the descending order of the document fragments according to the first target similarity. For example, from a massive number of document fragments, the 50 document fragments with the highest first target similarity can be selected as candidate document fragments. Then, the importance of each candidate document fragment can be determined based on its contextual position and logical relationship within its source document, and this importance can be mapped to an importance score.
[0152] D3: Based on the first target similarity and importance scores, select multiple target document fragments from multiple first candidate document fragments.
[0153] In practice, the retrieval service module can be used to directly multiply the primary target similarity and importance score of each first candidate document segment to obtain a secondary score for each candidate document segment (i.e., secondary score = primary target similarity × importance score). For example, if the primary target similarity of a first candidate document segment is 0.85 and its importance score is 0.3, its secondary score is 0.255. Based on the secondary score, the first candidate document segments are sorted and filtered in descending order, selecting target document segments that meet the preset filtering conditions (such as ranking the top 10 in secondary score). Alternatively, the retrieval service module can use a pre-trained scoring model to calculate the secondary score, that is, inputting the primary target similarity and importance score of each first candidate document segment into the secondary scoring model to obtain a secondary score in the range of 0-1. For example, if the primary target similarity of a first candidate document segment is 0.82 and its importance score is 0.3, the secondary scoring model calculates a secondary score of 0.68, which retains the original similarity features and incorporates structural importance factors. Finally, the optimal target document segments are selected based on the secondary score ranking.
[0154] In one embodiment, D3 above can be implemented according to the following steps E1 to E4:
[0155] E1: Using the first weight corresponding to the first target similarity and the second weight corresponding to the importance score, the first target similarity and importance score are weighted to obtain the target score of the first candidate document fragment.
[0156] Here, the first weight is a pre-set weight coefficient for the first target similarity, which can be used to adjust the contribution ratio of semantic relevance to the target score. For example, when the first weight is set to 0.7, it indicates that when calculating the target score, more emphasis is placed on the semantic matching degree between the document fragment and the question and answer statement, while the importance score is used as an auxiliary adjustment factor.
[0157] The second weight is a pre-set weighting coefficient for importance scoring, which can be used to adjust the contribution of the continuity of document fragment structure to the target score. For example, when the second weight is set to 0.3, it means that the system will take the importance of the fragment's structural position in the original text as an important auxiliary basis when calculating the target score, which together with the first weight constitutes a complete evaluation system.
[0158] In practical implementation, for any first candidate document fragment, the retrieval service module can be used to calculate the target score by weighting the first target similarity and the importance score using the first weight corresponding to the first target similarity and the second weight corresponding to the importance score. For example, when processing a first candidate document fragment, the first weight of 0.7 is multiplied by the first target similarity of 0.85, and the second weight of 0.3 is multiplied by the importance score of 0.3. Finally, the target score of the first candidate document fragment is obtained through the weighted formula "target score = 0.85 × 0.7 + 0.3 × 0.3 = 0.685". This value will be used as the basis for re-ranking when selecting target document fragments in the future. Based on the first and second weights, an optimal balance between semantic relevance and structural importance can be achieved, thereby further strengthening the structural authority of the fragment while ensuring semantic relevance, forming a high-quality contextual input.
[0159] E2: Based on the target score, select multiple second candidate document fragments from the first candidate document fragments.
[0160] Here, the second candidate document fragments are document fragments further filtered from the first candidate document fragments based on the target score. They serve as intermediate results of the hierarchical filtering process for subsequent processing. For example, from 50 first candidate document fragments, 15 fragments with a target score greater than 0.65 are selected as second candidate document fragments. By integrating semantic relevance and structural importance in a secondary filtering process, the quality of the selected second candidate document fragments can be improved.
[0161] In practice, the re-ranking unit in the retrieval service module can be used to select first candidate documents with a target score greater than the target score threshold (e.g., 0.7) as second candidate document fragments. For example, a first candidate document fragment with a target score of 0.72 is successfully filtered, while another first candidate document fragment with a score of 0.58 is eliminated, ultimately resulting in multiple second candidate document fragments of higher quality, providing an optimized data foundation for subsequent processing.
[0162] Alternatively, the re-sorting unit in the retrieval service module can be used to filter the second candidate document fragments through a sorting and filtering mechanism. For example, all first candidate document fragments can be sorted in descending order according to their target scores, and then the first candidate document fragments with the highest descending sort order (M) can be used as the second candidate document fragments. M can be set empirically, and this embodiment does not impose a specific limitation; for example, M can be 20, 25, etc.
[0163] Alternatively, the re-ranking unit in the retrieval service module can be used to dynamically filter second candidate document fragments through distribution analysis of target scores. For example, the distribution of target scores can be determined based on the target scores of each first candidate document fragment. Based on this distribution and preset filtering rules (such as taking the top 30% quantile), the target number of second candidate document fragments to be filtered can be determined. Then, based on the target score, the target number of second candidate document fragments can be filtered from the first candidate document fragments. For example, when processing the question "Key technologies of federated learning in medical data privacy protection", the target scores of all first candidate document fragments are first calculated. Then, the distribution characteristics of the target scores are analyzed, and it is found that the scores are mainly concentrated in the 0.5-0.8 range and are right-skewed. According to the corresponding filtering rules, the number of documents corresponding to the top 30% quantile is taken as the filtering base. Finally, the top 18 fragments are selected from 60 first candidate document fragments as second candidate document fragments.
[0164] E3: Based on the document identifier of each second candidate document fragment, determine whether there is a third candidate document fragment in the second candidate document that needs to be merged.
[0165] Here, the document identifier is a unique identification code assigned to each document / document fragment, used to establish the association between each document fragment and the source document during document fragment processing. If multiple second candidate document fragments correspond to the same document identifier, it means that these multiple second candidate document fragments belong to the same document fragment. To improve document coherence during LLM processing, multiple second candidate document fragments can be merged. If no second candidate document fragments with the same document identifier exist, it can be determined that document merging is not necessary.
[0166] The third candidate document fragment is a fragment of the second candidate document fragment, and this fragment exists in the second candidate document fragment with other second candidate document fragments having the same document identifier.
[0167] In practice, the reordering unit in the retrieval service module can be used to determine, for each second candidate document fragment, whether there exists a target second candidate document fragment with the same document identifier as the first second candidate document fragment, based on the document identifier of the second candidate document fragment and the document identifiers of other second candidate document fragments. If so, the second candidate document fragment and the target second candidate document fragment can be used as third candidate document fragments to be merged. If not, it can be determined that the second candidate document fragment does not need to be merged.
[0168] E4: If so, merge the third candidate document fragment to obtain the merged target document fragment; and take the other document fragments in the second candidate document fragment other than the third candidate document fragment as the target document fragment.
[0169] Here, the target document fragment includes the document fragment after merging the third candidate documents and the second candidate document fragments that were not merged. When two or more third candidate document fragments are detected to have the same document identifier and continuous content, they are merged into a unified target document fragment; at the same time, other document fragments in the second candidate document fragments that do not need to be merged are directly used as the target document fragment, ultimately forming a contextual material set that is both complete and accurate. By merging third candidate document fragments with the same document identifier and logically continuous content, the fragmentation problem caused by traditional segmented retrieval is effectively overcome. This ensures both the completeness and logical coherence of contextual information, and optimizes the utilization of computing resources by reducing the number of redundant fragments, achieving a synergistic improvement in retrieval accuracy and generation efficiency.
[0170] In practical implementation, when the existence of third candidate document fragments is confirmed, a reordering unit can be used to merge multiple third candidate document fragments with the same document identifier to obtain the merged target document fragment. If multiple third candidate document fragments with the same document identifier have different descending sorting orders, the order of the fragments with the earliest descending sorting order can be used as the order of the merged target document fragment. The merging process can be performed directly by merging the third candidate document fragments according to their order in the source document, or it can incorporate processing such as deduplication, hierarchical analysis, and sensitive word filtering to improve the reasonableness of the merged target document fragment. In this way, by merging logically consecutive document fragments from the same document, a more complete context can be formed, preventing the LLM from receiving fragmented information and generating unreasonable response results.
[0171] Meanwhile, since large language models have limitations on the maximum document length they can process, to prevent the merged target document fragments from exceeding this limit, a word count check can be performed on the merged fragments. If the word count exceeds the text processing capability threshold of the language model, the fragments can be split according to corresponding logical processing rules (such as three logical units: technical architecture, data processing, and application scenario) and the maximum document length, resulting in individual target document fragments. A "continued from above" marker is then inserted into each subsequent fragment to ensure the continuity of the generated content when the large language model generates its response. Additionally, all document fragments in the second candidate fragment group, except for the third candidate fragment, can be directly used as target document fragments.
[0172] Optionally, after obtaining the merged document fragments, their content can be compressed to reduce the amount of data. If the compressed document fragments still exceed the text processing capability threshold, the document can be split.
[0173] In this way, after accessing the initial result set, the scoring is optimized by a re-ranking algorithm based on context importance, and document fragments that meet the continuity condition in the same document are logically merged, which can improve the accuracy of the retrieved target document fragments and form the optimal set of document fragments for input into the language model.
[0174] Optionally, to enhance the impact of target document fragments with different scores on the answer results, after obtaining each target document fragment, weighted prompts can be assigned to each fragment based on its target score. Then, the target document fragments, preset prompts, weighted prompts, and question-and-answer statements are concatenated to obtain target prompts, which are then input into the LLM model for processing. This allows the LLM model to generate more reasonable answer results based on the weighted prompts. If the target document fragments include merged and then split document fragments, the corresponding "continued from previous context" marker can be concatenated into the target prompts, enabling the LLM model to generate more reasonable answer results based on the "continued from previous context" marker and the context.
[0175] Optionally, to further improve the rationality of the retrieved target document fragments, post-processing nodes (such as code nodes) can be set for the retrieval service module. After the retrieval service module determines the target document fragments, the post-processing nodes can be called to perform post-processing on the retrieved target document fragments, such as filtering fragments with insufficient length and supplementing document source information, thereby ensuring the quality of the document fragments supplied to the LLM model.
[0176] In one embodiment, to improve fault detection and recovery capabilities during the question-and-answer process, the question-and-answer method provided in this application also includes a real-time monitoring mechanism across the entire process. Specifically, for the above S101~S105, real-time monitoring can also be implemented according to the following steps F1~F3:
[0177] F1: In response to a monitoring request triggered for any question-and-answer processing step, obtain the corresponding operational metrics information for that step.
[0178] Here, the question-and-answer processing step can be any of the steps in S101~S105 and various subordinate implementation steps of S101~S105 described above. The monitoring request is used to detect the operational indicator information corresponding to any question-and-answer processing step. For example, when using different modules or nodes in the question-and-answer system for question-and-answer processing, the monitoring request can be used to detect the operational status of any node in the question-and-answer processing flow and the availability of each module. The monitoring request can include both periodically triggered health check requests and event-driven anomaly detection requests. This embodiment solves the problem of weak fault perception and recovery capabilities in traditional question-and-answer systems by establishing a full-link real-time monitoring mechanism, achieving real-time perception of the operational status of the question-and-answer processing flow and rapid anomaly localization, effectively improving the efficiency of system fault detection and handling, thereby ensuring the continuity and reliability of the question-and-answer service.
[0179] Operational metrics are a set of quantitative data reflecting the operational status of question-and-answer processing steps. They are used to evaluate the health and performance of the question-and-answer system, including but not limited to response time, availability, and resource utilization (CPU / memory) metrics for each question-and-answer processing step or each module / node executing the step. For example, a question-and-answer system can construct a multi-dimensional evaluation system for the system's operational status by collecting metrics such as the response latency of the API service module (e.g., an average of 235 milliseconds), the vector matching time of the retrieval service (e.g., 120 milliseconds), and the token output rate of the generation service (e.g., 850 tokens / second), providing data support for anomaly detection and performance optimization.
[0180] In practical implementation, the question-and-answer system can also include a monitoring service module, which may include an indicator collection unit, an early warning rule unit, a notification unit, and a log recording unit. Specifically, the indicator collection unit within the monitoring service module can use timed probe requests (such as Prometheus requests) to collect operational indicator information corresponding to any question-and-answer processing step or each module / node executing a question-and-answer processing step, based on the interface service module as the monitoring entry point of the question-and-answer system. For example, it can collect operational indicator information (such as response time, availability, and resource utilization (CPU / memory)) of any node in the interface service module, dynamic workflow orchestration module, retrieval service module, generation service module, and dynamic workflow orchestration module. Simultaneously, the interface service module, as the monitoring entry point of the question-and-answer system, can also check its own operational status through a health check interface, and simultaneously probe the availability of the large language model service, the preset vector database, and the workflow engine (such as n8n) through socket connections, HTTP requests, etc., providing comprehensive real-time data support for evaluating the operational status of question-and-answer processing. For example, when the question-answering system triggers a monitoring request for the vector retrieval service through a timed probe request, it automatically sends a probe command to the retrieval service calling node, and synchronously collects multi-dimensional operating indicators, including response latency (detection value is 150 milliseconds), queries per second (QPS), concurrency (current value is 285), and vector matching accuracy (statistical value is 96.8%). This data is then encapsulated into structured indicator information and transmitted to its analysis engine to provide real-time data support for system status assessment.
[0181] F2: Based on the operational metrics information, determine whether there are any anomalies in the question and answer processing steps.
[0182] In practical implementation, the early warning rule unit in the monitoring service module can be used to collect the operational indicator information of each module / node in real time through the indicator collection unit. This information is then compared with preset multi-level early warning thresholds. Once the operational indicator of any service module / node exceeds any level of early warning threshold, the system will immediately mark that service module / node and its corresponding question-and-answer processing steps as an abnormal state. Different levels of early warning thresholds correspond to different levels of abnormality. Each operational indicator information can be pre-set with different levels of early warning thresholds and alarm levels associated with those thresholds. For example, a response time > 500 milliseconds (ms) for any module / node triggers a low-level early warning, while an unavailability of any module / node triggers the highest-level early warning.
[0183] For example, in specific monitoring and detection, if it is found that the average response latency of a certain service module reaches 620 milliseconds for three consecutive sampling periods, and the error rate rises to 7.2%, it can be determined that there is a service anomaly in the service module and its corresponding question and answer processing steps based on the multi-level early warning threshold, and the subsequent early warning process can be triggered.
[0184] F3: If yes, generate exception message and / or log records related to document processing steps.
[0185] Here, the anomaly alert information is structured warning data generated by the system when it detects a service anomaly. It includes, but is not limited to, information elements such as anomaly type identifier, anomaly module / node / step information, timestamp, and indicator details, used to convey a precise fault description to the operations and maintenance system. For example, when a retrieval service response timeout is detected, the system generates an anomaly alert information containing the code "ALARM-1003", "retrieval service module", the timestamp "2024-06-15T10:30:Z", and details such as "3 consecutive timeouts, average latency > 800ms". This information is pushed to the operations and maintenance platform via a webhook for rapid fault location.
[0186] Log records are standardized fault archives automatically generated by the system when an anomaly is detected. They fully record the environmental snapshot and execution context at the time of the anomaly, including but not limited to call chain information (such as service node IP, request ID, and the order in which services / nodes are called), request parameters (such as query statements, request parameters during calls, model configurations, etc.), and memory overflow error stacks. For example, when a timeout anomaly occurs in the retrieval service, a log record is automatically generated containing key information such as the anomaly timestamp (2024-06-15T10:30:25Z), service identifier, input parameters ({"query": "deep search privacy protection", "top_k": 50}), error stack ("ConnectionTimeout: no response for more than 1500ms"), and system load (CPU utilization 92%). This structured data provides a complete source tracing basis for subsequent fault analysis.
[0187] In practice, when an anomaly is detected in any module / node and its corresponding question-and-answer processing step, the notification unit in the monitoring service module can be used to determine the anomaly level based on the warning threshold corresponding to the operational indicator information of the anomaly block / node and its corresponding question-and-answer processing step. Then, an anomaly prompt message is generated based on the warning rule and pushed to the operational channels (such as the operation and maintenance platform and / or operation and maintenance personnel) via Webhook. At the same time, the logging unit in the monitoring service module is used to automatically capture information such as the call chain, request parameters, and error stack at the time of the anomaly and store it in the log system, thereby forming a complete log record that supports accurate fault tracing. For example, when the monitoring service module detects an anomaly in the vector retrieval service when processing the query "Application of Heterogeneous Computing Platform in Edge AI," with a response latency exceeding 800 ms, GPU memory usage reaching 95%, and an error rate exceeding 8%, the notification unit immediately triggers P0-level (resource overload) and P1-level (performance degradation) alerts simultaneously according to multi-level early warning rules. A composite alarm message, including node topology information, resource indicator matrices, and anomaly time series, is pushed to the operations and maintenance channels via Webhook. Simultaneously, the logging unit automatically captures end-to-end tracing data (including inter-service call relationships, resource scheduling sequences, and cache hit records), combining it with the system core dump file at the anomaly time point to form a logging system supporting multi-dimensional root cause analysis, achieving closed-loop processing from anomaly detection to root cause localization. If no anomalies are found in the question-and-answer processing steps, the next monitoring cycle continues.
[0188] Optionally, if a module / node in the question-and-answer system provides an API interface, the corresponding module / node can be invoked through the interface service module based on its API interface. In the dynamic workflow orchestration module, a second result processing node can also be set. Each time a module or node is invoked, the second result processing node can analyze and process the invocation result, thereby enabling anomaly detection and error messages. For example, after invoking a module's API using the interface service module, the second result processing node can analyze the invocation result to determine if there are any anomalies such as invocation failure, and further process the result to ensure its validity.
[0189] Based on the same inventive concept, embodiments of this application also provide a question-answering system that matches the question-answering method. For example... Figure 2The diagram illustrates a question-and-answer system provided in this embodiment. The system may include an interface service module 21, a dynamic workflow orchestration module 22, a retrieval service module 23, and a generation service module 24. The dynamic workflow orchestration module 22 includes at least a request receiving node 221, a conditional branch node 222, a retrieval service call node 223, and a generation service call node 224. By decoupling the question-and-answer system into multiple independent microservices, physical isolation and independent deployment of functional modules such as retrieval, generation, and monitoring are achieved. Each microservice communicates based on a standardized interface contract (HTTP), significantly improving the system's scalability and maintainability. This system architecture allows each service component to independently iterate its technology and scale its resources, effectively avoiding the problem of modifying core code due to adjustments to a single function in traditional tightly coupled architectures, reducing the complexity and risk of system upgrades. Simultaneously, the microservice architecture provides a flexible deployment foundation for introducing dynamic weight adjustments and multi-dimensional retrieval strategies, and facilitates refined monitoring and governance of key service nodes, thereby enhancing the overall system's resilience, maintainability, and iteration efficiency.
[0190] Interface service module 21 is used to receive question and answer requests initiated by users; the question and answer request includes question and answer statements and question and answer mode parameters;
[0191] Request receiving node 221, used to send the question-and-answer mode parameters to conditional branch node 222;
[0192] Conditional branch node 222 is used to call the retrieval service module 23 by using retrieval service call node 223 when the question-answering mode parameter is the first preset mode;
[0193] The retrieval service module 23 is used to determine the initial weight vectors corresponding to multiple preset retrieval dimensions based on the target intent type corresponding to the question and answer statement. The multiple preset retrieval dimensions include at least the document content dimension, document metadata dimension, and keyword dimension. Based on the question and answer keywords in the question and answer statement, the initial weight vectors corresponding to each preset retrieval dimension are adjusted to obtain the target weight vectors corresponding to each preset retrieval dimension. Based on the target weight vectors and the document data of each document to be matched under each preset retrieval dimension, multiple target document fragments that match the question and answer statement are determined, and the generation service module 24 is called using the generation service call node 124.
[0194] The generation service module 24 is used to generate answer results that match the question-and-answer request based on multiple target document fragments using a large language model 241.
[0195] Specifically, the interface service module 21 can send information such as the question-and-answer request and target intent type to the dynamic workflow orchestration module 22 via the webhook interface. The request receiving node 221 in the dynamic workflow orchestration module 22 can send the question-and-answer mode parameters from the request to the conditional branch node 222 for conditional judgment. The answer result can be displayed to the user through the user question-and-answer interface.
[0196] In one possible implementation, conditional branch node 222 is also used for:
[0197] When the question-and-answer mode parameter is the second preset mode, the generation service module 24 is called using the generation service call node 224.
[0198] The generation service module 24 is also used to generate answer results that match the question and answer request based on the question and answer request using a large language model 241; the first preset mode and the second preset mode correspond to different question and answer processing flows.
[0199] In one possible implementation, the retrieval service module 23 is specifically used for:
[0200] Obtain the target keyword library corresponding to each preset search dimension; the target keyword library includes a document content keyword library, a document metadata keyword library, and a keyword library based on statistical features;
[0201] Determine the keywords in the question and answer statements and their matching results with each target keyword database; the matching results include the number of keyword matches and / or the matched keywords.
[0202] Perform intent analysis on the question and answer statements to determine the intent probability of the question and answer statements under various preset intent types; the preset intent types include the target intent type.
[0203] Based on the matching results, intent probabilities, and text length of the question and answer statements corresponding to each target keyword library, the initial weight vectors corresponding to each preset search dimension are adjusted to obtain the target weight vector.
[0204] In one possible implementation, the retrieval service module 23 is specifically used for:
[0205] Based on the matching results corresponding to each target keyword database, determine the first adjustment strategy under each preset search dimension;
[0206] Based on the probability of each intent, determine the second adjustment strategy under each preset retrieval dimension;
[0207] Based on the text length of the question and answer statements, determine the third adjustment strategy under each preset search dimension;
[0208] Based on at least one of the first adjustment strategy, the second adjustment strategy, and the third adjustment strategy, the initial weight vectors corresponding to each preset search dimension are adjusted to obtain the target weight vector.
[0209] In one possible implementation, the retrieval service module 23 is specifically used for:
[0210] Based on the document content vectors of document fragments of each document to be matched in the preset vector database in the document content dimension, and the question and answer vectors corresponding to the question and answer statements, the first similarity between the question and answer statements and each document fragment is determined.
[0211] Based on the document metadata vectors of each document fragment in the preset vector database under the document metadata dimension, and the question-and-answer vectors corresponding to the question-and-answer statements, the second similarity between the question-and-answer statements and each document fragment is determined; the document metadata vectors include at least the file path vector, topic classification vector, outline structure vector, version time vector, and document source vector;
[0212] Based on the question-and-answer keywords in the question-and-answer statement and the document keywords in the document fragments of each document to be matched, the third similarity between the question-and-answer statement and each document fragment is determined;
[0213] Based on the target weight vector, first similarity, second similarity, and third similarity, multiple target document fragments are selected from the document fragments of each document to be matched.
[0214] In one possible implementation, the retrieval service module 23 is specifically used for:
[0215] For any document fragment, the first similarity, second similarity and third similarity of the document fragment are weighted using the target weight vector under each preset retrieval dimension to obtain the first target similarity of the document fragment;
[0216] Based on the first target similarity, multiple first candidate document fragments are selected from the document fragments; based on the importance of each first candidate document fragment in the document to be matched, the importance score of each first candidate document fragment is determined.
[0217] Based on the first target similarity and importance scores, multiple target document fragments are selected from multiple first candidate document fragments.
[0218] In one possible implementation, the retrieval service module 23 is specifically used for:
[0219] By using the first weight corresponding to the first target similarity and the second weight corresponding to the importance score, the first target similarity and importance score are weighted to obtain the target score of the first candidate document fragment;
[0220] Based on the target score, multiple second candidate document fragments are selected from the first candidate document fragments;
[0221] Based on the document identifier of each second candidate document fragment, determine whether there is a third candidate document fragment in the second candidate document that needs to be merged;
[0222] If so, the third candidate document fragment is merged to obtain the merged target document fragment; and the other document fragments in the second candidate document fragment, excluding the third candidate document fragment, are taken as the target document fragment.
[0223] In one possible implementation, the question-and-answer system further includes a monitoring service module 25, which is used for:
[0224] In response to a monitoring request triggered for any module and / or node, the system obtains the corresponding operational metrics information for the module and / or node. The modules include an interface service module 21, a dynamic workflow orchestration module 22, a retrieval service module 23, and a generation service module 24. The nodes include a request receiving node 221, a conditional branch node 222, a retrieval service call node 223, and a generation service call node 224.
[0225] Based on operational metrics information, determine whether there are any anomalies in the modules and / or nodes;
[0226] If so, an error message and / or log entry will be generated.
[0227] The module can be any module in the question-and-answer system, such as the interface service module, dynamic workflow orchestration module, retrieval service module, and generation service module. The node can be any node in the dynamic workflow orchestration module, such as the request receiving node, conditional branch node, retrieval service call node, and generation service call node.
[0228] Based on real-time monitoring of modules and / or nodes, not only can the question-and-answer processing steps corresponding to modules and / or nodes be monitored in real time, but also the availability of the modules and / or nodes themselves can be monitored. By integrating a full-link real-time monitoring mechanism, the problem of weak fault detection and recovery capabilities in traditional systems can be solved. By using the interface service module as the monitoring entry point, real-time, passive health detection is performed on all key microservices such as LLM, preset vector database, and workflow engine to ensure high system availability.
[0229] For example, it can not only check itself using the health check interface of the interface service module, but also simultaneously probe the availability of the LLM model, the preset vector database, and the workflow engine through Socket connections, HTTP requests, etc., providing multi-point synchronous status reports. Furthermore, once any module / node is detected to have an abnormal status code or a response time exceeding a preset threshold, it can immediately trigger early warning notifications and log recordings, enabling rapid fault location and handling.
[0230] In one possible implementation, the dynamic workflow orchestration module 22 is further configured to:
[0231] The question-and-answer process, consisting of various modules and nodes, is visualized using a graphical interface.
[0232] In response to editing operations on the question-and-answer process, edit the target nodes and / or target modules related to the editing operation.
[0233] Here, this embodiment uses a graphical interface to visualize and edit the question-and-answer process, enabling users / administrators to intuitively perceive the overall business process architecture and directly modify node logic and module relationships through interactive methods such as dragging and connecting lines. This effectively reduces the technical threshold and operational complexity of system process adjustments, realizes flexible customization and real-time optimization of business processes, and significantly improves the maintainability and scalability of the system.
[0234] The graphical user interface (GUI) is a human-computer interaction interface that visually displays and edits the question-and-answer system workflow. It uses components such as a node library, workflow canvas, and configuration panel to intuitively present and dynamically modify the workflow structure. For example, users can drag and drop a new preprocessing node 225 into the interface service module 21 on the workflow canvas and set validation rule parameters through the property panel. The system maps these editing operations to logical changes in the actual business process in real time. The preprocessing node 225 can be used for preprocessing and intent analysis of user requests. As another example, a new result processing node 226 can be added to the generation service module to perform format conversion and other processing on the generated answer results.
[0235] Editing operations are configuration changes performed on nodes and modules in the question-and-answer process through a graphical interface. They include operations such as adding nodes, replacing modules, adjusting logical relationships, and reconfiguring parameters.
[0236] In practical implementation, the dynamic workflow orchestration module 22 can be used to graphically display and dynamically edit the entire question-and-answer system process through a visual configuration interface. Users / administrators can intuitively view the complete process chain from request reception and condition judgment to retrieval and generation calls in the graphical interface. When the business process needs to be optimized according to user question-and-answer requirements, users / administrators can modify the question-and-answer process processing logic by dragging and dropping, add result preprocessing nodes after generating answer results and / or add preprocessing nodes before request reception nodes by clicking the node addition button, and set the desensitization rule to "ID number mask processing" through the attribute panel. The question-and-answer system parses the editing operation in real time and reconstructs the execution chain, so that all subsequent question-and-answer requests will automatically perform data desensitization processing after the retrieval results are returned, realizing process optimization and function expansion without modifying the underlying code. In this way, through visual process management, it is possible to modify process logic, add nodes, or replace services through a graphical interface, ensuring that configuration changes take effect in real time, greatly reducing the difficulty of operation and maintenance and expansion.
[0237] For example, the question-and-answer processing flow can be visualized and modified through the n8n web interface. This includes adding a "multi-turn dialogue memory node" or an "external API verification node." The multi-turn dialogue memory node can be invoked after the target document fragment is determined to automatically retrieve multi-turn historical question-and-answer information related to the question and answer statements. This multi-turn historical question-and-answer information, the target document fragment, and preset prompts are then concatenated into a target prompt word, which is input into the LLM model, further improving the accuracy of the answers generated by the LLM model. The external API verification node can also be invoked after the target document fragment is determined to check the rationality of the selected target document fragments, avoiding the selection of document fragments with poor usability. When the flow is modified, all configuration changes take effect in real time without restarting the service or modifying the underlying system code, improving the scalability of the question-and-answer system and reducing its maintenance costs.
[0238] For a description of the question-and-answer processing flow of each module / node in the question-and-answer system, as well as the interaction flow between each module, please refer to the relevant descriptions in the above-mentioned question-and-answer method embodiments, which will not be detailed here.
[0239] like Figure 3The flowchart shown in this embodiment illustrates a question-answering method. The algorithm targets a first preset mode. In this mode, upon receiving a user's question-answering request, the system first performs semantic analysis and intent recognition to output the target intent type. The target intent type can be used to determine the initial weight vector during multi-dimensional hybrid retrieval. Subsequently, multi-dimensional hybrid retrieval is performed, namely: similarity is determined for each preset retrieval dimension through document content vector retrieval, document metadata vector retrieval, and keyword matching based on statistical features. Based on a dynamic weight adjustment mechanism, the initial weight vectors for each preset retrieval dimension are adjusted according to the constraint that each weight value is between 0 and 1 and their sum is 1, resulting in the target weight vector for each preset retrieval dimension. Then, based on the similarity under each preset retrieval dimension and the target weight vector, the first target similarity for each document fragment is determined, and based on the first target similarity, the first candidate document fragment is selected. In the re-ranking and merging stage, the re-ranking scoring formula (target score = first target similarity × first weight × importance score × second weight) is applied to rank and filter the first candidate document fragments, resulting in the second candidate document fragments. If a third candidate document fragment exceeds 500 characters in length after merging, it is split. Finally, the split third document fragment and the unmerged second candidate document fragments are used as the target document fragments. The target document fragment, question-and-answer statements, and preset prompts are concatenated and input into the LLM model to obtain the answer output by the LLM model and fed back to the user.
[0240] For a description of the specific implementation process of the question-and-answer method, please refer to the relevant descriptions in the above-mentioned question-and-answer method embodiments, which will not be detailed here.
[0241] For the system embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0242] like Figure 4The diagram shows a monitoring service flowchart for some services in a question-and-answer system provided in this embodiment. In its implementation, the interface service module first distributes probe requests to the interface service, vector database service, and workflow engine service, and obtains their returned running status and metrics. These metrics include response time, error codes, and load data. The monitoring service module then analyzes these metrics and determines if they are abnormal. If the metrics are normal, the system health status is updated, and periodic monitoring probes continue to be performed at predetermined time intervals. If the metrics are abnormal, an early warning process is triggered, including recording an anomaly log, pushing the early warning information to the corresponding maintenance channel, and generating an anomaly notification. After execution, the process enters a waiting state until the next monitoring cycle begins, at which point the above steps are repeated, thereby achieving continuous closed-loop monitoring of the running status of each service component and timely anomaly alerts.
[0243] For a description of the monitoring service process in the question-and-answer system, please refer to the relevant descriptions in the above-mentioned question-and-answer method embodiments, which will not be detailed here.
[0244] Based on the same technical concept, embodiments of this application also provide a computer device. (Refer to...) Figure 5 The diagram shown is a structural schematic of a computer device provided in an embodiment of this application, comprising:
[0245] The processor 501, memory 502, and bus 503 are included. Memory 502 stores machine-readable instructions executable by the processor 501. The processor 501 executes the machine-readable instructions stored in memory 502. When the machine-readable instructions are executed by the processor 501, the processor 501 executes the above-described S101~S104.
[0246] The aforementioned memory 502 includes a main memory 5021 and an external memory 5022. The main memory 5021, also known as internal memory, is used to temporarily store the computational data in the processor 501, as well as the data exchanged with external memory such as a hard disk 5022. The processor 501 exchanges data with the external memory 5022 through the main memory 5021. When the computer device is running, the processor 501 and the memory 502 communicate through the bus 503, so that the processor 501 executes the execution instructions mentioned in the above method embodiments.
[0247] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the question-and-answer method described in the above-described method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0248] This disclosure also provides a computer program product carrying program code. The program code includes instructions that can be used to execute the steps of the question-and-answer method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0249] The computer program product can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0250] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it can be understood that the disclosed system and method can be implemented in other ways. The system embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of the system or units may be electrical, mechanical, or other forms.
[0251] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0252] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0253] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A question and answer method, characterized by, The method comprises: receiving a user-initiated question and answer request; the question and answer request comprises a question and answer sentence and a question and answer mode parameter; in the case where the question and answer mode parameter is a first preset mode, determining an initial weight vector corresponding to each of a plurality of preset retrieval dimensions according to a target intent type corresponding to the question and answer sentence; the plurality of preset retrieval dimensions at least comprise a document content dimension, a document metadata dimension and a keyword dimension; obtaining a target keyword library corresponding to each of the preset retrieval dimensions; the target keyword library comprises a document content keyword library, a document metadata keyword library and a keyword library based on statistical characteristics; determining a matching result corresponding to each of the target keyword libraries for a question and answer keyword in the question and answer sentence; the matching result comprises a keyword matching number and / or a matching keyword; performing intent analysis on the question and answer sentence to determine an intent probability of the question and answer sentence under each preset intent type; the preset intent type comprises the target intent type; adjusting the initial weight vector corresponding to each of the preset retrieval dimensions based on the matching result corresponding to each of the target keyword libraries, the intent probability and the text length of the question and answer sentence to obtain a target weight vector corresponding to each of the preset retrieval dimensions; determining a plurality of target document segments matched with the question and answer sentence based on the target weight vector and document data of each to-be-matched document under each preset retrieval dimension; generating an answer result matched with the question and answer request based on the plurality of target document segments by using a large language model.
2. The method of claim 1, wherein, The method further comprises: in the case where the question and answer mode parameter is a second preset mode, generating an answer result matched with the question and answer request based on the question and answer sentence by using the large language model; the first preset mode and the second preset mode correspond to different question and answer processing procedures.
3. The method of claim 1, wherein, The adjusting of the initial weight vector corresponding to each of the preset retrieval dimensions based on the matching result corresponding to each of the target keyword libraries, the intent probability and the text length of the question and answer sentence to obtain the target weight vector corresponding to each of the preset retrieval dimensions comprises: determining a first adjustment strategy under each of the preset retrieval dimensions according to the matching result corresponding to each of the target keyword libraries; determining a second adjustment strategy under each of the preset retrieval dimensions according to each of the intent probabilities; determining a third adjustment strategy under each of the preset retrieval dimensions according to the text length of the question and answer sentence; adjusting the initial weight vector corresponding to each of the preset retrieval dimensions based on at least one of the first adjustment strategy, the second adjustment strategy and the third adjustment strategy to obtain the target weight vector.
4. The method of claim 1, wherein, The determining of the plurality of target document segments matched with the question and answer sentence based on the target weight vector and the document data of each to-be-matched document under each preset retrieval dimension comprises: determine a first similarity between the question-answer statement and each of the document segments according to a document content vector of each of the document segments in the preset vector database in the document content dimension, and a question-answer vector corresponding to the question-answer statement; determine a second similarity between the question-answer statement and each of the document segments according to a document metadata vector of each of the document segments in the preset vector database in the document metadata dimension, and the question-answer vector corresponding to the question-answer statement; the document metadata vector at least includes a file path vector, a subject classification vector, an outline structure vector, a version time vector, and a document source vector; determine a third similarity between the question-answer statement and each of the document segments according to a question-answer keyword in the question-answer statement and a document keyword in each of the document segments of the to-be-matched documents; screen a plurality of target document segments from each of the document segments of the to-be-matched documents based on the target weight vector, the first similarity, the second similarity, and the third similarity.
5. The method of claim 4, wherein, The screening of the plurality of target document segments from each of the document segments of the to-be-matched documents based on the target weight vector, the first similarity, the second similarity, and the third similarity includes: for any one of the document segments, weighting the first similarity, the second similarity, and the third similarity corresponding to the document segment by using the target weight vector in each of the preset retrieval dimensions to obtain a first target similarity of the document segment; screen a plurality of first candidate document segments from the document segment according to the first target similarity; and determine an importance score of each of the first candidate document segments according to an importance of each of the first candidate document segments; screen a plurality of the target document segments from the plurality of first candidate document segments according to the first target similarity and the importance score.
6. The method of claim 5, wherein, The screening of the plurality of the target document segments from the plurality of first candidate document segments according to the first target similarity and the importance score includes: weighting the first target similarity and the importance score by using a first weight corresponding to the first target similarity and a second weight corresponding to the importance score to obtain a target score of the first candidate document segment; screen a plurality of second candidate document segments from the first candidate document segment according to the target score; determine whether a third candidate document segment that needs to be merged exists in the second candidate document according to a document identifier of each of the second candidate document segments; if yes, merge the third candidate document segment to obtain a merged target document segment; and take other document segments in the second candidate document segment except the third candidate document segment as the target document segment.
7. The method of claim 1, wherein, The method further includes: in response to a monitoring request triggered for any question-answer processing step, obtaining running index information corresponding to the question-answer processing step; determine whether the question-answer processing step is abnormal according to the running index information; If yes, an exception prompt information and / or a log record related to the document processing step is generated.
8. A question answering system, characterized by The question and answer system comprises an interface service module, a dynamic workflow arrangement module, a retrieval service module and a generation service module; the dynamic workflow arrangement module comprises at least a request receiving node, a conditional branch node, a retrieval service calling node and a generation service calling node; wherein: The interface service module is configured to receive a question and answer request initiated by a user; the question and answer request comprises a question and answer statement and a question and answer mode parameter; The request receiving node is configured to send the question and answer mode parameter to the conditional branch node; The conditional branch node is configured to, in a case where the question and answer mode parameter is a first preset mode, call the retrieval service module by using the retrieval service calling node; The retrieval service module is configured to determine an initial weight vector corresponding to each of a plurality of preset retrieval dimensions according to a target intent type corresponding to the question and answer statement; the plurality of preset retrieval dimensions comprise at least a document content dimension, a document metadata dimension and a keyword dimension; obtain a target keyword library corresponding to each of the preset retrieval dimensions; the target keyword library comprises a document content keyword library, a document metadata keyword library and a keyword library based on statistical characteristics; determine a matching result of a question and answer keyword in the question and answer statement and each of the target keyword libraries; the matching result comprises a keyword matching number and / or a matching keyword; perform intent analysis on the question and answer statement to determine an intent probability of the question and answer statement under each preset intent type; the preset intent type comprises the target intent type; adjust the initial weight vector corresponding to each of the preset retrieval dimensions based on the matching result corresponding to each of the target keyword libraries, the intent probability and a text length of the question and answer statement to obtain a target weight vector corresponding to each of the preset retrieval dimensions; determine a plurality of target document segments matched with the question and answer statement based on the target weight vector and document data of each to-be-matched document under each preset retrieval dimension, and call the generation service module by using the generation service calling node; The generation service module is configured to generate an answer result matched with the question and answer request based on the plurality of target document segments by using a large language model.
9. The system of claim 8, wherein, The conditional branch node is further configured to: In a case where the question and answer mode parameter is a second preset mode, call the generation service module by using the generation service calling node; The generation service module is further configured to generate an answer result matched with the question and answer request based on the question and answer request by using a large language model; the first preset mode and the second preset mode correspond to different question and answer processing procedures.
10. The system of claim 8, wherein, The retrieval service module is specifically configured to: determine a first adjustment strategy under each of the preset retrieval dimensions according to the matching result corresponding to each of the target keyword libraries; determine a second adjustment strategy under each of the preset retrieval dimensions according to each of the intent probabilities; determine a third adjustment strategy under each of the preset retrieval dimensions according to the text length of the question and answer statement; According to at least one of the first adjustment strategy, the second adjustment strategy, and the third adjustment strategy, the initial weight vector corresponding to each of the preset retrieval dimensions is adjusted to obtain the target weight vector.
11. The system of claim 8, wherein, The retrieval service module is specifically configured to: According to a document content vector of each of the document segments of the to-be-matched documents in the preset vector database under the document content dimension and a question and answer vector corresponding to the question and answer statement, a first similarity corresponding to each of the document segments and the question and answer statement is determined. According to a document metadata vector of each of the document segments of the to-be-matched documents in the preset vector database under the document metadata dimension and the question and answer vector corresponding to the question and answer statement, a second similarity corresponding to each of the document segments and the question and answer statement is determined; the document metadata vector at least includes a file path vector, a topic classification vector, an outline structure vector, a version time vector, and a document source vector. According to a question and answer keyword in the question and answer statement and a document keyword in each of the document segments of the to-be-matched documents, a third similarity corresponding to each of the document segments and the question and answer statement is determined. Based on the target weight vector, the first similarity, the second similarity, and the third similarity, a plurality of target document segments are screened from the document segments of the to-be-matched documents.
12. The system of claim 11, wherein, The retrieval service module is specifically configured to: For any one of the document segments, the target weight vector under each of the preset retrieval dimensions is used to weight the first similarity, the second similarity, and the third similarity corresponding to the document segment to obtain a first target similarity of the document segment. According to the first target similarity, a plurality of first candidate document segments are screened from the document segment; according to the importance of each of the first candidate document segments, an importance score of each of the first candidate document segments is determined. According to the first target similarity and the importance score, a plurality of the target document segments are screened from the plurality of first candidate document segments.
13. The system of claim 12, wherein, The retrieval service module is specifically configured to: The first target similarity and the importance score are weighted by using a first weight corresponding to the first target similarity and a second weight corresponding to the importance score to obtain a target score of the first candidate document segment. According to the target score, a plurality of second candidate document segments are screened from the first candidate document segment. According to a document identifier of each of the second candidate document segments, it is determined whether there is a third candidate document segment that needs to be merged in the second candidate document. If yes, the third candidate document segment is merged to obtain a merged target document segment; and other document segments in the second candidate document segment except the third candidate document segment are taken as target document segments.
14. The system of claim 8, wherein, The system further includes a monitoring service module, and the monitoring service module is configured to: In response to a triggering of a monitoring request for any module and / or node, obtaining running index information corresponding to the module and / or node; the modules include the interface service module, the dynamic workflow orchestration module, the retrieval service module and the generation service module, and the nodes include the request receiving node, the conditional branch node, the retrieval service calling node and the generation service calling node; According to the running index information, determining whether the module and / or node is abnormal; If yes, generating an abnormal prompt information and / or a log record.
15. The system of claim 8, wherein, The dynamic workflow orchestration module is further configured to: Using a graphical interface, visually displaying a question and answer process composed of each module and each node; In response to an editing operation on the question and answer process, performing editing processing on a target node and / or a target module related to the editing operation.
16. A computer readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the steps of the method of any one of claims 1 to 7.
17. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the computer program comprises computer program code configured to cause the processor to perform the method of any one of claims 1 to 16. The processor executes the program to implement the steps of the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Interaction method and device, server and computer readable storage medium
CN119938836A
RAG method and system for compliance analysis of multi-modal financial document
CN120407878A
Interaction processing method and electronic equipment
CN120631942A