Large language model knowledge base question answering system based on multi-path fusion recall retrieval algorithm
By introducing a dynamic weight allocation module into the knowledge base question and answer system of the large language model, the recall weights are dynamically adjusted for different semantic scenarios, which solves the problem that traditional algorithms are difficult to adapt to different semantic scenarios, and achieves more efficient and accurate knowledge recall and question and answer services.
Patent Information
- Application Number
- CN202411808314.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-06-13
AI Technical Summary
Traditional multi-channel fusion recall retrieval algorithms are difficult to adapt to the Q&A requirements in different semantic scenarios, and fixed weights are difficult to meet the needs of different semantic scenarios such as technology and product query.
Through the dynamic weight allocation module, the weights of each recall are dynamically allocated for different semantic clusters, combined with semantic analysis and correlation scores, the recall weights are adjusted to adapt to different semantic scenarios.
Effectively optimize recall results, accurately screen knowledge related to questions, reduce interference with irrelevant information, improve recall accuracy, enhance system adaptability, and improve answer quality and system efficiency.
Smart Images

Figure CN120144773A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of artificial intelligence applications, and particularly relates to a large language model knowledge base question-answering system based on a multi-channel fusion recall retrieval algorithm. Background Art
[0002] The large models are iterating rapidly, and various manufacturers have launched their own large models. The technologies and related products of large models are being updated daily, and the technology is developing extremely fast. Among them, knowledge-based question answering is a relatively common and important application scenario, and many domestic manufacturers are also actively exploring the application of knowledge question answering in various professional fields by using open-source large models.
[0003] In traditional multi-channel fusion recall retrieval algorithms, each recall path often uses fixed weights for fusion, making it difficult to adapt to the question-answering requirements in different semantic scenarios. For example, in a question-answering scenario in a technical field, semantic similarity recall may be more important because technical questions often require a more accurate understanding of the semantics of the questions. In a product query scenario, keyword matching recall may be relatively more important because users may be more inclined to use specific keywords to query product information. To address the above problems, the following solutions are proposed. Summary of the Invention
[0004] The purpose of the present invention is to provide a large language model knowledge base question-answering system based on a multi-channel fusion recall retrieval algorithm. Through a dynamic weight allocation module, weights for each recall are dynamically allocated for different semantic clusters, solving the problem that existing algorithms are difficult to adapt to the question-answering requirements in different semantic scenarios.
[0005] To solve the above technical problems, the present invention is implemented through the following technical solutions:
[0006] The present invention is a large language model knowledge base question-answering system based on a multi-channel fusion recall retrieval algorithm. The working process of the question-answering system is as follows:
[0007] Step S1, data collection: The data collection module collects knowledge documents from multiple data sources and screens them in a unified format;
[0008] Step S2, data preprocessing: The knowledge documents are preprocessed through the data preprocessing module;
[0009] Step S3, knowledge base construction: A knowledge graph is constructed through the knowledge base construction module, the processed text is converted into a vector form, and an index is built to complete the establishment of the knowledge base;
[0010] Step S4, analysis and clustering: Through in-depth analysis and clustering of a large amount of historical question-answering data by the semantic cluster division module, different semantic patterns are identified, and semantic clusters and their characteristics are determined;
[0011] Step S5, Knowledge Recall: For the user's question, relevant knowledge is mined from the knowledge base through a multi-channel recall module, and a variety of recall methods are comprehensively used to recall knowledge fragments related to the question;
[0012] Step S6, Weight Adjustment: Through the dynamic weight allocation module, semantic analysis is performed on the user's question to determine the semantic cluster to which it belongs, calculate the correlation scores of the recall results of each channel with the question, and dynamically adjust the recall weights of each channel according to the question semantic cluster and the recall result correlation;
[0013] Step S7, Weight Fusion: Through the dynamic weight fusion module, the results recalled by each channel are fused according to the dynamic weights to obtain a fused result set;
[0014] Step S8, Re-ranking: Through the re-ranking module, the fused recall results are re-ranked by integrating multiple factors;
[0015] Step S9, Knowledge Screening: The knowledge fragments are screened out through the screening module;
[0016] Step S10, Knowledge Feedback: Through the output module, the screened knowledge is used as context and combined with the prompt to input into the large language model, and the large language model is used to answer and feedback to the user.
[0017] Preferably, the specific process of constructing the knowledge graph in the above-mentioned Step S3, Constructing the Knowledge Base is as follows:
[0018] Step S31, Knowledge Extraction;
[0019] Step S32, Knowledge Fusion;
[0020] Step S33, Knowledge Storage: Select a graph database, represent entities with nodes and relationships with edges, and store the knowledge graph according to the requirements of the graph database;
[0021] The above-mentioned Step S31, Knowledge Extraction includes the following steps:
[0022] Step S311, Entity Extraction: Using deep learning methods to identify entities from text data and other data sources, and using deep learning models to extract entities;
[0023] Step S312, Relationship Extraction: Obtain relationships between entities through unsupervised learning methods, train classifiers to judge relationship types, and use clustering analysis to unsupervised discover potential relationships;
[0024] Step S313, Attribute Extraction: Extract attribute information of entities from the data;
[0025] The above-mentioned Step S32, Knowledge Fusion includes the following steps:
[0026] Step S321, entity alignment: Align the same or similar entities extracted from different data sources;
[0027] Step S322, knowledge merging: Integrate knowledge from different sources and remove redundancy.
[0028] Preferably, when converting the text in the knowledge base into vector form in step S3, the deep semantic model BERT is used to convert the processed text into vector form, enabling semantic similarity calculation of the text in the vector space.
[0029] Preferably, when building an index in step S3, building a knowledge base, an inverted index is established, with keywords as index items, associating the knowledge document fragments containing the keywords, and at the same time building a vector index.
[0030] Preferably, the specific process of analysis and clustering in step S4, analysis and clustering is as follows:
[0031] Step S41: Use a large amount of historical Q&A data collected as a training set;
[0032] Step S42: Use the unsupervised clustering algorithm K_Means to perform semantic clustering on the questions in the training set, and divide questions with similar semantics into the same cluster;
[0033] Step S43: Extract and analyze the features of each semantic cluster, determine its main semantic features and keywords, build a semantic cluster feature library, analyze the features of each semantic cluster, extract the main semantic features and keywords, form a semantic cluster feature library, and use the TF_IDF method to determine the keyword weights.
[0034] Preferably, the specific steps of multiple recall methods in step S5, knowledge recall are as follows:
[0035] Step S51, recall based on keyword matching: Search for knowledge entries matching the question keywords in the inverted index;
[0036] Step S52, vector recall based on semantic similarity: Calculate the cosine similarity between the question vector q and the vector k i of the knowledge entry in the knowledge base. The formula is: Recall knowledge entries according to the similarity;
[0037] Step S53, recall based on the knowledge graph: When the question involves entity relationships, use the knowledge graph to retrieve relevant entities and relationships and recall relevant knowledge.
[0038] Preferably, the specific process of calculating the correlation score in step S6, dynamic weight adjustment is as follows:
[0039] Step S61: Calculate the similarity between the question and the features of each semantic cluster, and assign the question to a semantic cluster. Let the set of semantic clusters be C = {c 1 , c 2 , …, c m}, the question vector be q, and the feature vector of semantic cluster c i be v j . The similarity between the question and semantic cluster c i is calculated as:
[0040] Select the semantic cluster with the highest similarity as the semantic cluster to which the question belongs;
[0041] Step S62: Calculate the relevance scores between the recall results of each path and the question: Let the result set recalled based on keyword matching be R k = {r k1 , r k2 , …, r kn}, the result set recalled based on semantic similarity vector be R s = {r s1 , r s2 , …, r sp}, and the result set recalled based on the knowledge graph be R g = {r g1 , r g2 , …, r gq};
[0042] Step S63: Dynamically adjust the weights;
[0043] The specific steps of step S62 include the following steps:
[0044] Step S621: Calculate the relevance score for the recall result of keyword matching:
[0045] C k (r ki ) = TF_IDF(r ki , q);
[0046] In the formula, TF_IDF is the calculation of term frequency - inverse document frequency, r ki is the i-th result in the result set R k recalled based on keyword matching, and q is the user's question vector;
[0047] Step S622: Calculate the relevance score for the recall result of semantic similarity vector:
[0048] C s (r si ) = Similarity(q, r si );
[0049] Wherein, Similarity(q,r si ) represents the semantic similarity between the user's question vector q and the recall result r si , r si is the i-th result in the result set R s recalled based on the semantic similarity vector;
[0050] Step S623: For the relevance score of the knowledge graph recall result:
[0051] C g (r gi ) = KG_Score(r gi , q);
[0052] Wherein, KG_Score(r gi , q) represents the relevance score between the recall result r gi based on the knowledge graph and the user's question vector q, r gi is the i-th result in the result set R g recalled based on the knowledge graph.
[0053] Preferably, the step S63 of dynamically adjusting the weights specifically includes the following steps:
[0054] Step S631: Determine the initial weights of each recall according to the semantic cluster to which it belongs. Let the recall weight based on keyword matching be w k , the recall weight based on semantic similarity vector recall be w s , and the recall weight based on the knowledge graph be w g . Let the adjustment coefficient be α. For the adjustment of the keyword matching recall weight:
[0055]
[0056] Wherein, n is the number of recall results based on keyword matching, and C k (r ki ) is the relevance score of the i-th keyword matching recall result r ki ;
[0057] Step S632: For the adjustment of the semantic similarity vector recall weight:
[0058]
[0059] Wherein, p is the number of recall results based on semantic similarity vector recall, and C s (r si ) is the relevance score of the i-th semantic similarity vector recall result r si ;
[0060] Step S633: Adjust the recall weight for the knowledge graph:
[0061]
[0062] In the formula, q is the number of recall results based on the knowledge graph, and C g (r gi ) is the relevance score of the i-th knowledge graph recall result r gi .
[0063] Preferably, in step S7, weight fusion, the fused score F(r i ) is: Obtain the fused result set;
[0064] In the formula, w′ k is the adjusted recall weight for keyword matching, w s ′ is the adjusted recall weight for semantic similarity vector, w′ g is the adjusted recall weight for the knowledge graph, C k (r ki ) is the relevance score of the keyword matching recall result, C s (r si ) is the relevance score of the semantic similarity vector recall result, C g (r gi ) is the relevance score of the knowledge graph recall result, R k is the result set based on keyword matching recall, R s is the result set based on semantic similarity vector recall, R g is the result set based on knowledge graph recall.
[0065] Preferably, in step S8, re-ranking, the specific ranking method is:
[0066] Let the timeliness weight be w t , and the source reliability weight be w r , then the comprehensive score calculation formula is:
[0067] Score(r i ) = w corr ×F(r i ) + w t ×T(r i ) + w r ×R(r i );
[0068] In the formula, where T(r i ) is the timeliness score of the knowledge fragment r i , and R(r i ) is the knowledge fragment ri Source reliability score, w corr is the relevance score weight, and according to the set sorting basis, the fused recall result set is re-sorted.
[0069] The present invention has the following beneficial effects:
[0070] 1. By setting a dynamic weight allocation module, the present invention can flexibly adjust the recall weights of various types such as keyword matching, semantic similarity, and knowledge graph for different semantic scenarios such as technical categories and product query categories. This can effectively optimize the recall results, accurately screen the knowledge related to the problem, reduce the interference of irrelevant information, improve the recall accuracy, and at the same time enhance the system adaptability to cope with semantic diversity and data changes, provide high-quality materials for subsequent modules, improve the answer quality and system efficiency, and thus improve user satisfaction.
[0071] 2. The data collection source of the present invention is extensive, and it can process various formats of documents. The knowledge base construction integrates multi-technology to process knowledge and adapts to different data characteristics. The semantic cluster division uses unsupervised learning to cope with various problem types. The multi-way recall and dynamic weight mechanism can switch strategies according to the problem semantic scenario. This design enables the system to flexibly cope with situations such as the expansion of the knowledge field and the change of user needs, and stably and efficiently operate in different application scenarios, continuously providing high-quality Q&A services for users.
[0072] Of course, it is not necessary for any product implementing the present invention to achieve all the above-mentioned advantages simultaneously. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.
[0074] Figure 1 is the internal system framework diagram of the present invention;
[0075] Figure 2 is the internal system framework diagram of the dynamic weight allocation module of the present invention;
[0076] Figure 3 is the internal system framework diagram of the knowledge base construction module of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0077] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0078] Please refer to Figures 1-3 As shown, the present invention is a large language model knowledge base question-answering system based on a multi-channel fusion recall retrieval algorithm, and the working process of the question-answering system is as follows:
[0079] Step S1, data collection: The data collection module collects knowledge documents from multiple data sources and screens them in a unified format;
[0080] Step S2, data preprocessing: Preprocess the knowledge documents through the data preprocessing module;
[0081] Step S3, build a knowledge base: Build a knowledge graph through the knowledge base building module, convert the processed text into a vector form, build an index, and complete the establishment of the knowledge base;
[0082] Step S4, analysis and clustering: Deeply analyze and cluster a large amount of historical question-answer data through the semantic cluster division module, identify different semantic patterns, and determine the semantic clusters and their characteristics;
[0083] Step S5, knowledge recall: Through the multi-channel recall module, for the user's question, mine relevant knowledge from the knowledge base, comprehensively use multiple recall methods, and recall knowledge fragments related to the question;
[0084] Step S6, weight adjustment: Semantically analyze the user's question through the dynamic weight allocation module, determine the semantic cluster to which it belongs, calculate the correlation score between each recall result and the question, and dynamically adjust the recall weights of each channel according to the question semantic cluster and the recall result correlation;
[0085] Step S7, weight fusion: Fuse the results recalled by each channel according to the dynamic weights through the dynamic weight fusion module to obtain a fused result set;
[0086] Step S8, reordering: Reorder the fused recall results through the reordering module by integrating multiple factors;
[0087] Step S9, knowledge screening: Screen out knowledge fragments through the screening module;
[0088] Step S10, knowledge feedback: Use the output module to input the screened knowledge as context and prompt into the large language model, and use the large language model to answer and feedback to the user.
[0089] Step S3. The specific process of constructing a knowledge graph in the knowledge base is as follows:
[0090] Step S31. Knowledge extraction;
[0091] Step S32. Knowledge fusion;
[0092] Step S33. Knowledge storage: Select a graph database, represent entities as nodes and relationships as edges, and store the knowledge graph according to the requirements of the graph database;
[0093] Step S31. Knowledge extraction includes the following steps:
[0094] Step S311. Entity extraction: Use deep learning methods to identify entities from text data and other data sources, and extract entities using a deep learning model;
[0095] Step S312. Relationship extraction: Obtain relationships between entities through unsupervised learning methods, train a classifier to judge the relationship type, and use clustering analysis to unsupervisedly discover potential relationships;
[0096] Step S313. Attribute extraction: Extract attribute information of entities from the data;
[0097] Step S32. Knowledge fusion includes the following steps:
[0098] Step S321. Entity alignment: Align the same or similar entities extracted from different data sources;
[0099] Step S322. Knowledge merging: Integrate knowledge from different sources and remove redundancy.
[0100] Step S3. When converting text in the knowledge base into vector form, use the deep semantic model BERT to convert the processed text into vector form, enabling semantic similarity calculation of the text in the vector space.
[0101] Step S3. When building an index in the knowledge base, establish an inverted index, use keywords as index items, associate the knowledge document fragments containing the keywords, and build a vector index at the same time.
[0102] Step S4. The specific process of analysis and clustering is as follows:
[0103] Step S41: Use a large amount of historical Q&A data collected as the training set;
[0104] Step S42: Use the unsupervised clustering algorithm K_Means to perform semantic clustering on the questions in the training set, and divide questions with similar semantics into the same cluster;
[0105] Step S43: Extract and analyze features for each semantic cluster, determine its main semantic features and keywords, construct a semantic cluster feature library. For each semantic cluster, conduct feature analysis, extract the main semantic features and keywords to form a semantic cluster feature library, and use the TF_IDF method to determine the keyword weights.
[0106] Step S5. The specific steps of various recall methods in knowledge recall are as follows:
[0107] Step S51. Recall based on keyword matching: Search for knowledge entries that match the problem keywords in the inverted index;
[0108] Step S52. Vector recall based on semantic similarity: Calculate the cosine similarity between the problem vector q and the vectors k of knowledge entries in the knowledge base. The formula is: i Recall knowledge entries according to the similarity; Step S53. Recall based on the knowledge graph: When the problem involves entity relationships, use the knowledge graph to retrieve relevant entities and relationships and recall relevant knowledge.
[0109] Step S6. The specific process of calculating the relevance score in dynamic weight adjustment is as follows:
[0110] Step S61: Calculate the similarity between the problem and the features of each semantic cluster, and assign the problem to a semantic cluster. Let the semantic cluster set be C = {c
[0111] , c 1 , …, c 2 , …, c m}, the problem vector is q, and the feature vector of the semantic cluster c i is v j . The similarity calculation between the problem and the semantic cluster c i is:
[0112] Select the semantic cluster with the highest similarity as the semantic cluster to which the problem belongs;
[0113] Step S62: Calculate the relevance scores of the recall results of each path to the problem. Let the result set of recall based on keyword matching be R k = {r k1 , r k2 , …, r kn}, the result set of recall based on semantic similarity vector is R s = {r s1 , r s2 , …, r sp}, and the result set of recall based on the knowledge graph is R g = {r g1 , r g2 , …, rgq};
[0114] Step S63: Dynamically adjust the weights;
[0115] Step S62 specifically includes the following steps:
[0116] Step S621: Calculate the relevance score for the keyword matching recall results:
[0117] C k (r ki ) = TF_IDF(r ki , q);
[0118] In the formula, TF_IDF is the term frequency - inverse document frequency calculation, r ki is the i-th result in the keyword matching recall result set R k , and q is the user's question vector;
[0119] Step S622: Calculate the relevance score for the semantic similarity vector recall results:
[0120] C s (r si ) = Similarity(q, r si );
[0121] In the formula, Similarity(q, r si ) represents the semantic similarity between the user's question vector q and the recall result r si , and r si is the i-th result in the recall result set R s based on the semantic similarity vector recall;
[0122] Step S623: Calculate the relevance score for the knowledge graph recall results:
[0123] C g (r gi ) = KG_Score(r gi , q);
[0124] In the formula, KG_Score(r gi , q) represents the relevance score between the recall result r gi based on the knowledge graph and the user's question vector q, and r gi is the i-th result in the recall result set R g based on the knowledge graph recall.
[0125] Step S63: Dynamically adjusting the weights specifically includes the following steps:
[0126] Step S631: Determine the initial weights recalled by each route according to the semantic cluster to which they belong. Let the recall weight based on keyword matching be w k , the recall weight of vector recall based on semantic similarity be w s , and the recall weight of knowledge graph-based recall be w g . Let the adjustment coefficient be α. For the recall weight adjustment of keyword matching:
[0127]
[0128] In the formula, n is the number of recall results based on keyword matching, and C k (r ki ) is the relevance score of the i-th keyword matching recall result r ki ;
[0129] Step S632: For the recall weight adjustment of vector recall based on semantic similarity:
[0130]
[0131] In the formula, p is the number of recall results of vector recall based on semantic similarity, and C s (r si ) is the relevance score of the i-th vector recall result based on semantic similarity r si ;
[0132] Step S633: For the recall weight adjustment of knowledge graph-based recall:
[0133]
[0134] In the formula, q is the number of recall results based on the knowledge graph, and C g (r gi ) is the relevance score of the i-th knowledge graph recall result r gi ;
[0135] Step S7: In the weight fusion, the fused score F(r i ) is: Obtain the fused result set;
[0136] In the formula, w′ k is the adjusted recall weight of keyword matching, w s ′ is the adjusted recall weight of vector recall based on semantic similarity, w′ g is the adjusted recall weight of knowledge graph-based recall, C k (r ki ) is the relevance score of the keyword matching recall result, and C s (r si ) is the relevance score of the vector recall result based on semantic similarity, Cg (r gi ) is the relevance score of the knowledge graph recall result, R k is the result set recalled based on keyword matching, R s is the result set recalled based on semantic similarity vectors, R g is the result set recalled based on the knowledge graph.
[0137] Step S8, the sorting method in re - sorting is specifically as follows:
[0138] Let the timeliness weight be w t , and the source reliability weight be w r , then the comprehensive score calculation formula is:
[0139] Score(r i ) = w corr ×F(r i ) + w t ×T(r i ) + w r ×R(r i ),
[0140] In the formula, where T(r i ) is the timeliness score of the knowledge fragment r i , R(r i ) is the source reliability score of the knowledge fragment r i , w corr is the relevance score weight, and according to the set sorting basis, the fused recall result set is re - sorted.
[0141] A specific application of this embodiment is:
[0142] Step S1, data collection: The data collection module collects and organizes various types of knowledge documents, including but not limited to text files, PDFs, web data, etc., collects knowledge documents from multiple data sources, such as local file systems, databases, web pages obtained by web crawlers, etc., unifies the format and conducts preliminary screening;
[0143] Step S2, data pre - processing: The data pre - processing module pre - processes the knowledge documents, such as text cleaning (removing noise, special symbols, etc.), word segmentation, part - of - speech tagging, etc. Operations are performed to clean the text using natural language processing techniques, remove noise such as HTML tags and special characters, and perform Chinese word segmentation and part - of - speech tagging;
[0144] Step S3, building a knowledge base: Build a knowledge graph through the data processed by the knowledge base building module. The specific process is as follows:
[0145] Step S31, knowledge extraction includes:
[0146] Step S311, Entity Extraction: Entities are identified from text data and other data sources using rule-based, machine learning, or deep learning methods. For example, in the medical field, based on rules, specific medical terms and sentence patterns can be used to identify entities such as drugs and diseases. Machine learning models (such as support vector machines and conditional random fields) or deep learning models (such as BERT) can be trained with a large amount of labeled data to accurately extract entities.
[0147] Step S312, Relationship Extraction: Relationships between entities are obtained through manual templates, supervised learning, or unsupervised learning methods. For example, in the business field, manual templates can be written to identify relationships such as "acquisition" and "cooperation" between companies, or a classifier can be trained to determine the type of relationship, or clustering analysis can be used to unsupervised discover potential relationships.
[0148] Step S313, Attribute Extraction: Attribute information of entities is extracted from the data, such as attributes like "establishment time" and "headquarters location" of "Apple Inc.".
[0149] Step S32, Knowledge Fusion includes:
[0150] Step S321, Entity Alignment: For the same or similar entities extracted from different data sources, such as "aspirin" and "acetylsalicylic acid", methods such as string similarity calculation and semantic similarity calculation are used to align them.
[0151] Step S322, Knowledge Merging: Knowledge from different sources is integrated to remove redundancy, such as merging information about a certain drug from multiple databases.
[0152] Step S33, Knowledge Storage: A suitable graph database (such as Neo4j, JanusGraph, etc.) is selected, with nodes representing entities and edges representing relationships, and the knowledge graph is stored according to the requirements of the graph database to make it a part of the knowledge base, facilitating subsequent retrieval and application based on the knowledge graph.
[0153] Step S34, Text Vectorization: The processed text is converted into vector form using the deep semantic model BERT, enabling semantic similarity calculation of the text in the vector space. This step mainly targets the text knowledge part in the knowledge base except for the structured representation of the knowledge graph, facilitating retrieval in the form of vector indexing.
[0154] Step S35, Index Construction: An inverted index is established, with keywords as index terms, associating the knowledge document fragments containing the keywords. At the same time, a vector index is constructed to facilitate fast retrieval based on semantic similarity, and to ensure the effective connection and application of the knowledge graph in the overall knowledge base retrieval system, enabling multiple retrieval methods to work together and providing strong support for the entire question-answering system.
[0155] Through the above steps, the construction of a knowledge base in multiple forms including a knowledge graph, an inverted index, and a vector index is completed;
[0156] Step S4, Analysis and Clustering:
[0157] Step S41: The semantic cluster division module uses a large amount of historical Q&A data collected as the training set, ensuring that the data covers different fields and topics;
[0158] Step S42: Use the unsupervised clustering algorithm K_Means to perform semantic clustering on the questions in the training set, dividing questions with similar semantics into the same cluster. For example, cluster questions about technical issues, business process issues, product consultation issues, etc. separately. Use the K_Means unsupervised clustering algorithm to cluster the questions, and adjust the parameters to make the clustering result optimal to obtain the semantic cluster set;
[0159] Step S43: Extract and analyze the features of each semantic cluster, determine its main semantic features and keywords, and construct a semantic cluster feature library. Analyze the features of each semantic cluster, extract the main semantic features and keywords, form a semantic cluster feature library, and use methods such as TF_IDF to determine the keyword weights;
[0160] Step S5, Knowledge Recall: When the multi-channel recall module receives a new question from the user, it first preprocesses the question, including operations such as text cleaning and word segmentation, and then uses a text vectorization model to convert the question into a vector representation, performing the same text preprocessing and vector conversion operations as when constructing the knowledge base on the user's input question;
[0161] At the same time, start the multi-channel recall algorithm, such as recall based on keyword matching (using the inverted index), vector recall based on semantic similarity, recall based on the knowledge graph, etc.;
[0162] Step S51, Recall Based on Keyword Matching: Search for knowledge entries in the inverted index that match the question keywords;
[0163] Step S52, Vector Recall Based on Semantic Similarity: Calculate the cosine similarity between the question vector q and the vector k of the knowledge entry in the knowledge base i The formula is: Recall the knowledge entries with higher similarity;
[0164] Step S53, Recall Based on the Knowledge Graph: If the question involves entity relationships, use the knowledge graph to retrieve relevant entities and relationships and recall relevant knowledge;
[0165] Step S6, Weight Adjustment:
[0166] Step S61: Perform semantic analysis on the user's question through the dynamic weight allocation module to determine the semantic cluster it belongs to. For example, by calculating the similarity between the question and the features of each semantic cluster, allocate it to the most similar semantic cluster. Let the semantic cluster set be C = {c 1 , c 2 , …, c m}, the question vector be q, and the feature vector of semantic cluster c i be v j . Then the similarity between the question and semantic cluster c i is calculated as follows:
[0167]
[0168] Select the semantic cluster with the highest similarity as the semantic cluster to which the question belongs;
[0169] Step S62: Determine the initial weights for each recall path according to the belonging semantic cluster. Let the recall weight based on keyword matching be w k , the recall weight based on semantic similarity vector be w s , and the recall weight based on knowledge graph be w g . The initial weights are set as follows (can be adjusted according to the actual situation):
[0170] If the belonging semantic cluster is technical, w s = 0.5, w k = 0.3, w g = 0.2;
[0171] If the belonging semantic cluster is business process, w k = 0.5, w s = 0.3, w g = 0.2;
[0172] If the belonging semantic cluster is product consultation, w k = 0.4, w s = 0.4, w g = 0.2;
[0173] Calculate the relevance scores between the recall results of each path and the question: Let the result set of recall based on keyword matching be R k = {r k1 , r k2 , …, r kn}, the result set of recall based on semantic similarity vector be R s = {r s1 , r s2 , …, r sp}, and the result set of recall based on knowledge graph be R g = {r g1 , r g2,…,r gq};
[0174] Step S621: Calculate the relevance score for the keyword matching recall results:
[0175] C k (r ki ) = TF_IDF(r ki , q), where TF_IDF is the term frequency - inverse document frequency calculation;
[0176] Step S622: Relevance score for the semantic similarity vector recall results:
[0177] C s (r si ) = Similarity(q, r si );
[0178] Step S623: Relevance score for the knowledge graph recall results (set according to factors such as entity relationship matching degree): C g (r gi ) = KG_Score(r gi , q);
[0179] Step S63: Dynamically adjust the weights:
[0180] Step S631: Let the adjustment coefficient be α for adjusting the keyword matching recall weight:
[0181]
[0182] In the formula, n is the number of keyword matching recall results, and C k (r ki ) is the relevance score of the i-th keyword matching recall result r ki ;
[0183] Step S632: Adjust the semantic similarity vector recall weight:
[0184]
[0185] In the formula, p is the number of semantic similarity vector recall results, and C s (r si ) is the relevance score of the i-th semantic similarity vector recall result r si ;
[0186] Step S633: Adjust the knowledge graph recall weight:
[0187]
[0188] where q is the number of recall results based on the knowledge graph, C g (r gi ) is the relevance score of the i-th recall result r gi from the knowledge graph;
[0189] Step S7, Weight Fusion: The dynamic weight fusion module uses an adaptive fusion algorithm to fuse the recall results from each path according to dynamic weights:
[0190] Let the fused score F(r i ) be: Obtain the fused recall result set;
[0191] Step S8, Re-ranking: The re-ranking module comprehensively considers factors such as relevance score, timeliness of knowledge fragments, and source reliability to determine the priority and weight assignment for ranking. Let the timeliness weight be w t , and the source reliability weight be w r . Then the comprehensive score calculation formula is:
[0192] Score(r i ) = w corr ×F(r i ) + w t ×T(r i ) + w r ×R(r i ),
[0193] where T(r i ) is the timeliness score of the knowledge fragment r i , R(r i ) is the source reliability score of the knowledge fragment r i , w corr is the relevance score weight. According to the set ranking basis, re-rank the fused recall result set and place the most relevant, reliable, and up-to-date knowledge fragments at the front;
[0194] Step S9, Knowledge Screening: The screening module screens out a certain number of top-ranked knowledge entries as the final recall results. For example, select the top 5 to 10 most relevant pieces of knowledge. According to the system settings, select a certain number of top-ranked knowledge entries as the final results;
[0195] Step S10, Knowledge Feedback: The output module inputs the screened knowledge entries as context into the trained large language model;
[0196] Design a prompt template to guide the large language model to generate accurate and clear answers based on the input knowledge items. For example, "The following is the knowledge related to the question: [content of knowledge items], please answer the question based on this knowledge: [user's question]". Carefully design the prompt template to clearly inform the large language model of the question and related knowledge, and guide it to generate targeted answers;
[0197] The large language model generates an answer based on the input context and prompt and returns it to the user.
[0198] In the description of this specification, the descriptions referring to the terms "one embodiment", "example", "specific example", etc. mean that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0199] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made according to the content of this specification. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and utilize the present invention well. The present invention is only limited by the claims and their full scope and equivalents.
Claims
1. A large language model knowledge base question answering system based on a multi-channel fusion recall retrieval algorithm, characterized in that: The workflow of the question-answering system is as follows: Step S1, data collection: the data collection module collects knowledge documents from various data sources and screens them in a unified format; Step S2, data preprocessing: preprocessing the knowledge document through a data preprocessing module; Step S3, building a knowledge base: building a knowledge graph through a knowledge base building module, converting the processed text into a vector form, building an index, and completing the establishment of the knowledge base; Step S4, analysis and clustering: deep analysis and clustering of a large amount of historical question and answer data through the semantic clustering module, identifying different semantic patterns, and determining semantic clusters and their characteristics; Step S5, knowledge recall: using the multi-channel recall module to mine relevant knowledge from the knowledge base for user questions, and comprehensively using multiple recall methods to recall knowledge fragments related to the questions; Step S6, weight adjustment: The dynamic weight allocation module performs semantic analysis on the user's question, determines the semantic cluster to which it belongs, calculates the relevance score between each recall result and the question, and dynamically adjusts the recall weight of each recall according to the relevance between the question semantic cluster and the recall result; Step S7, weight fusion: The results of each recall are fused according to the dynamic weights through the dynamic weight fusion module to obtain a fused result set; Step S8, re-ranking: re-ranking the fused recall results by integrating multiple factors through the re-ranking module; Step S9, knowledge screening: screening out knowledge fragments through the screening module; Step S10, knowledge feedback: The filtered knowledge is input into the large language model as context and prompts through the output module, and the large language model is used to answer and feedback the user.
2. According to claim 1, a large language model knowledge base question answering system based on a multi-channel fusion recall retrieval algorithm is characterized in that: The specific process of constructing the knowledge graph in step S3, constructing the knowledge base, is as follows: Step S31, knowledge extraction; Step S32: knowledge fusion; Step S33, knowledge storage: select a graph database, use nodes to represent entities, edges to represent relationships, and store the knowledge graph according to the requirements of the graph database; The step S31, knowledge extraction, comprises the following steps: Step S311, entity extraction: using deep learning methods to identify entities from text data and other data sources, and using deep learning models to extract entities; Step S312, relationship extraction: obtain the relationship between entities through unsupervised learning methods, train classifiers to determine the relationship type, and use cluster analysis to discover potential relationships without supervision; Step S313, attribute extraction: extracting entity attribute information from the data; The step S32, knowledge fusion, comprises the following steps: Step S321, entity alignment: aligning the same or similar entities extracted from different data sources; Step S322, knowledge merging: integrating knowledge from different sources and removing redundancy.
3. According to claim 1, a large language model knowledge base question answering system based on a multi-channel fusion recall retrieval algorithm is characterized in that: In the step S3, when converting the text in the knowledge base into a vector form, the deep semantic model BERT is used to convert the processed text into a vector form, so that the semantic similarity of the text can be calculated in the vector space.
4. According to claim 1, a large language model knowledge base question answering system based on a multi-channel fusion recall retrieval algorithm is characterized in that: In the step S3, when building an index in the knowledge base, an inverted index is established, with keywords as index items, knowledge document fragments containing the keywords are associated, and a vector index is built at the same time.
5. According to claim 1, a large language model knowledge base question answering system based on a multi-channel fusion recall retrieval algorithm is characterized in that: The specific process of analysis and clustering in step S4, analysis and clustering is as follows: Step S41: using the collected large amount of historical question-and-answer data as a training set; Step S42: Use the unsupervised clustering algorithm K_Means to perform semantic clustering on the questions in the training set, and divide the questions with similar semantics into the same cluster; Step S43: Extract and analyze features of each semantic cluster, determine its main semantic features and keywords, build a semantic cluster feature library, perform feature analysis on each semantic cluster, extract main semantic features and keywords, form a semantic cluster feature library, and use the TF_IDF method to determine keyword weights.
6. According to claim 1, a large language model knowledge base question answering system based on a multi-channel fusion recall retrieval algorithm is characterized in that: The multiple recall methods in step S5, knowledge recall, specifically include the following steps: Step S51, recall based on keyword matching: searching for knowledge items matching the question keywords in the inverted index; Step S52, vector recall based on semantic similarity: calculate the vector k of the question vector q and the knowledge item in the knowledge base i The cosine similarity of is: Recall knowledge items based on similarity; Step S53, recall based on knowledge graph: When the question involves entity relationships, use the knowledge graph to retrieve relevant entities and relationships and recall relevant knowledge.
7. According to claim 1, a large language model knowledge base question answering system based on a multi-channel fusion recall retrieval algorithm is characterized in that: The specific process of calculating the correlation score in step S6, dynamically adjusting the weight, is as follows: Step S61: Calculate the similarity between the question and each semantic cluster feature, assign the question to a semantic cluster, and set the semantic cluster set as C = {c1, c2, ..., c m }, question vector is q, semantic cluster is c i The eigenvector of j , question and semantic cluster c i The similarity is calculated as: Select the semantic cluster with the highest similarity as the semantic cluster to which the question belongs; Step S62: Calculate the relevance score between each recall result and the question: Let the result set based on keyword matching be R k = {r k1 ,r k2 ,…,r kn }, the result set based on semantic similarity vector recall is R s = {r s1 ,r s2 ,…,r sp }, the result set based on the knowledge graph is R g = {r g1 ,r g2 ,…,r gq }; Step S63, dynamically adjusting weights; The step S62 specifically includes the following steps: Step S621: Calculate the relevance score of the keyword matching recall results: C k (r ki )=TF_IDF(r ki ,q); In the formula, TF_IDF is the term frequency-inverse document frequency calculation, r ki Recall result set R based on keyword matching k The i-th result in , q is the question vector asked by the user; Step S622: Relevance score for the semantic similarity vector recall result: C s (r si )=Similarity(q,r si ); In the formula, Similarity(q,r si ) represents the user's question vector q and the recall result r si The semantic similarity of si is the result set R based on semantic similarity vector recall s The i-th result in ; Step S623: Relevance score for knowledge graph recall results: C g (r gi )=KG_Score(r gi ,q); In the formula, KG_Score(r gi ,q) represents the recall result r based on the knowledge graph gi The relevance score with the user's question vector q, r gi is the result set R based on the knowledge graph recall g The i-th result in .
8. According to claim 7, a large language model knowledge base question answering system based on a multi-channel fusion recall retrieval algorithm is characterized in that: The step S63, dynamically adjusting the weight, specifically comprises the following steps: Step S631: Determine the initial weight of each recall according to the semantic cluster to which it belongs, and set the recall weight based on keyword matching as w k , the vector recall weight based on semantic similarity is w s , the recall weight based on the knowledge graph is w g , let the adjustment coefficient be α, and adjust the recall weight for keyword matching: Where n is the number of recall results based on keyword matching, C k (r ki ) is the i-th keyword matching recall result r ki 's relevance score; Step S632: Adjust the recall weight of the semantic similarity vector: Where p is the number of recall results based on semantic similarity vectors, C s (r si ) is the recall result r of the i-th semantic similarity vector si 's relevance score; Step S633: Adjust the recall weight of the knowledge graph: In the formula, q is the number of recall results based on the knowledge graph, C g (r gi ) is the i-th knowledge graph recall result r gi The relevance score of .
9. The large language model knowledge base question answering system based on multi-channel fusion recall retrieval algorithm according to claim 1 is characterized in that: In step S7, the score F(r i )for: Get the fused result set; Where w′ k is the adjusted keyword matching recall weight, w′ s is the adjusted semantic similarity vector recall weight, w′ g is the adjusted knowledge graph recall weight, C k (r ki ) is the relevance score of the keyword matching recall result, C s (r si ) is the relevance score of the semantic similarity vector recall result, C g (r gi ) is the relevance score of the knowledge graph recall result, R k is the result set based on keyword matching recall, R s is the result set based on semantic similarity vector recall, R g It is the result set recalled based on the knowledge graph.
10. The large language model knowledge base question answering system based on multi-channel fusion recall retrieval algorithm according to claim 1, characterized in that: The specific sorting method in step S8, re-sorting, is: Let the timeliness weight be w t , the source reliability weight is w r , the comprehensive score calculation formula is: Score(r i )=w corr ×F(r i )+w t ×T(r i )+w r ×R(r i ); In the formula, T(r i ) is the knowledge fragment r i The timeliness score, R(r i ) is the knowledge fragment r i The source reliability score, w corr is the relevance score weight, and the fusion recall result set is reordered according to the set sorting criteria.
Citation Information
Patent Citations
Recommendation method and device, computer readable storage medium and electronic equipment
CN112115370A
Search sorting method and device
CN114064929A
Multi-path recall search rearrangement method and system based on multi-intention judgment, computer equipment and computer readable storage medium
CN114911834A
Patent retrieval method, device and equipment oriented to various retrieval scenes
CN116303989A
Vector model-based relevancy ranking method for multi-path recall semantics
CN116910388A
Cited By
Dynamic knowledge retrieval enhancement method based on large language model
CN120407570A
A method for dynamic knowledge retrieval enhancement based on large language model
CN120407570B
Knowledge graph-based traffic engineering large model intelligent question-answering system and method
CN120407752A
Intelligent question and answer enhancement method and system based on RAG technology
CN120723877A
Intelligent question answering enhancement method and system based on RAG technology
CN120723877B