Response large model retrieval enhancement method and device based on hierarchical cluster index structure
By adopting the response big model retrieval enhancement method with a hierarchical cluster index structure in the question-and-answer system, the problem of high resource consumption of knowledge graph construction and maintenance in the existing technology is solved, the accuracy and efficiency of complex queries are improved, and the occurrence of "illusion" phenomena is reduced.
Patent Information
- Application Number
- CN202411581489.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-11-07
AI Technical Summary
The use of hybrid search methods in the prior art in question-and-answer methods requires the construction and maintenance of knowledge graphs, which leads to large resource consumption and slow search speed, and is prone to "illusion" when processing complex queries, resulting in poor accuracy and efficiency balance of search results.
The response big model retrieval enhancement method based on the hierarchical cluster index structure is adopted. By sorting and feature weighting of user problem vectors, and searching with the topic layer and feature layer of the knowledge base, we reduce the dependence on the knowledge graph.
It improves the accuracy and retrieval efficiency of the response model when processing complex queries, reduces the "illusion" phenomenon that occurs during information retrieval, and reduces resource consumption.
Smart Images

Figure CN119760057A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data retrieval, and in particular to a method and device for enhancing retrieval of a large response model based on a hierarchical cluster index structure. Background Art
[0002] Document retrieval aims to search for the most relevant documents in response to a query and is widely used in many areas of natural language processing, such as question answering, dialogue, and recommendation systems.
[0003] In the related technology, a hybrid retrieval method is usually used to enhance the RAG question-answering method to convert text into vectors or construct document knowledge into a knowledge graph, and then use three hybrid methods of vector retrieval, keyword retrieval and knowledge graph retrieval in combination with user questions to retrieve relevant context. The hybrid retrieval has a slow retrieval speed, and building and maintaining a knowledge graph requires a lot of resources and effort. When the required document knowledge is large, building a knowledge graph is time-consuming. When the collected document knowledge is small, the retrieval accuracy is low. That is, the balance between the accuracy of the retrieval results and the retrieval efficiency obtained by this retrieval method is poor, and "hallucination" phenomenon is prone to occur when processing more complex query tasks. Summary of the invention
[0004] The present invention provides a method and device for enhancing retrieval of a large answer model based on a hierarchical cluster index structure, so as to solve the problem that the existing technology adopts a hybrid retrieval method to enhance the question-answering method, which requires a lot of resources and efforts to build and maintain a knowledge graph, resulting in a poor balance between the accuracy of the retrieval results and the retrieval efficiency, and is prone to the defect of "hallucination" phenomenon. The method improves the accuracy and relevance of the large answer model when processing complex queries, and reduces the "hallucination" phenomenon that occurs during the information retrieval process.
[0005] The present invention provides a method for enhancing retrieval of a large answer model based on a hierarchical cluster index structure, comprising: In the case where the user asks multiple rounds of questions, the question vectors of the first question are sorted based on the ranking retrieval technology of similarity to obtain a first question vector queue; the question vectors of the second question are similarly calculated with each vector in the first question vector queue and sorted according to the size of the similarity calculation results to obtain a second question vector queue; the second question is asked by the user later than the first question; Perform feature weighting on the second question vector and at least one vector in the second question vector queue that is adjacent to the second question vector to obtain a retrieval vector; According to the retrieval vector, a search is performed in the cluster of the subject layer of the knowledge base to obtain the target retrieval text, so as to supply the answer model with an answer result; wherein, the knowledge base is constructed by a hierarchical cluster index structure and a text online update mechanism; the hierarchical cluster index structure includes a subject layer, a feature layer and a text layer, and each subject vector in the subject layer is anchored to at least one document content vector in the feature layer.
[0006] According to a method for enhancing retrieval of a large answer model based on a hierarchical cluster index structure provided by the present invention, the knowledge base is constructed by the following steps: Extracting a first topic vector and a plurality of first document content vectors from the document to be input, and determining a first clustering parameter according to the first topic vector; the first clustering parameter includes a first cluster number and a first inter-cluster distance; Calculating the correlation between the plurality of first document content vectors, and adjusting the order of the first topic vectors and the initial topic vectors according to the correlation to obtain a first topic vector queue, wherein the initial topic vector is obtained based on a historical input document; Determine multiple first cluster core points from the first topic vector queue according to the first cluster parameter, and for each first cluster core point, recursively add neighbor nodes related to the first cluster core point to the same cluster through the first topic vector queue to obtain a topic layer of the knowledge base; The feature layer is based on sequentially calculating, sorting and clustering the vector correlation of the multiple first document content vectors.
[0007] According to a method for enhancing retrieval of a large answer model based on a hierarchical cluster index structure provided by the present invention, the knowledge base is updated online through the following steps: In the case where a new input document is created in the knowledge base, extracting a second topic vector and a plurality of second document content vectors from the new input document; Determining a second clustering parameter according to the plurality of second topic vectors; the second clustering parameter includes a second cluster number and a second inter-cluster distance; The second topic vector is merged into the first topic vector queue based on the ranking retrieval technology of similarity to obtain a second topic vector queue; Determine a plurality of second cluster core points from the second topic vector queue according to the second cluster parameter, and for each second cluster core point, recursively add neighbor nodes related to the second cluster core point to the same cluster through the second topic vector queue to obtain an updated topic layer of the knowledge base; Among them, each topic vector in the updated topic layer is anchored to at least one document content vector in the updated feature layer; the updated feature layer is based on vector correlation calculation, queue update, sorting and clustering acquisition of the multiple second document content vectors in sequence.
[0008] According to a method for enhancing retrieval of a large answer model based on a hierarchical cluster index structure provided by the present invention, before extracting a plurality of second topic vectors and a plurality of second document content vectors from the new input document, the method comprises: The new input document is cleaned and preprocessed to obtain a processed document; wherein the preprocessing includes word segmentation, and removal of stop words and punctuation marks.
[0009] According to a method for enhancing the retrieval of a large answer model based on a hierarchical cluster index structure provided by the present invention, the topic layer includes a plurality of topic vector clusters, and each topic vector includes a cluster core point; The searching in the clusters of the subject layer of the knowledge base according to the search vector to obtain the target search text comprises: Calculating the cosine similarity between the search vector and the cluster core points of each topic vector cluster to obtain multiple similarity calculation results; The topic index of the target topic vector cluster is determined according to the maximum value among the multiple similarity calculation results, the target document content vector is determined according to the topic index and the anchoring relationship between the topic vector and the document content vector, and the target retrieval text is determined according to the target document content vector.
[0010] According to a method for enhancing retrieval of a large answer model based on a hierarchical cluster index structure provided by the present invention, the step of performing feature weighting on the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector comprises: The search vector is calculated using the following formula: ; Among them, the is the search vector, is the second problem vector, is the i-th vector adjacent to the second problem vector, for The feature weights of .
[0011] The present invention also provides a method and device for enhancing the retrieval of a large answer model based on a hierarchical cluster index structure, comprising: A queue acquisition module is used to sort the question vectors of the first question based on the ranking retrieval technology of similarity to obtain a first question vector queue when the user asks multiple rounds of questions; calculate the similarity between the question vector of the second question and each vector in the first question vector queue and sort them according to the size of the similarity calculation results to obtain a second question vector queue; the second question is asked by the user later than the first question; a vector weighting module, configured to perform feature weighting on the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector; A retrieval module is used to search in the cluster of the subject layer of the knowledge base according to the retrieval vector to obtain the target retrieval text so as to supply the answer model with the answer result; wherein, the knowledge base is constructed by a hierarchical cluster index structure and a text online update mechanism; the hierarchical cluster index structure includes a subject layer, a feature layer and a text layer, and each subject vector in the subject layer is anchored with at least one document content vector in the feature layer.
[0012] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for enhancing the retrieval of a large response model based on a hierarchical cluster index structure as described above is implemented.
[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described methods for enhancing the retrieval of a large response model based on a hierarchical cluster index structure.
[0014] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements any of the above-mentioned methods for enhancing the retrieval of a large response model based on a hierarchical cluster index structure.
[0015] The answer big model retrieval enhancement method and device based on the hierarchical cluster index structure provided by the present invention obtains a first question vector queue by sorting the question vector of the first question; calculates the similarity between the question vector of the second question and each vector in the first question vector queue and sorts them according to the size of the similarity calculation results to obtain a second question vector queue; then performs feature weighting on the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector; finally, searches the clusters of the subject layer of the knowledge base according to the retrieval vector to obtain the target retrieval text, so as to output the answer result for the answer big model, thereby improving the accuracy and retrieval efficiency of the answer big model when processing complex queries and reducing the "hallucination" phenomenon occurring during the information retrieval process. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 It is a flow chart of the answer large model retrieval enhancement method based on the hierarchical cluster index structure provided by the present invention.
[0018] Figure 2 It is a structural schematic diagram of the large-scale answer model retrieval enhancement device based on the hierarchical cluster index structure provided by the present invention.
[0019] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0021] Combine the following Figure 1-Figure 2 The present invention describes a method and device for enhancing the retrieval of a large response model based on a hierarchical cluster index structure.
[0022] Figure 1 This is one of the flow charts of the answer large model retrieval enhancement method based on the hierarchical cluster index structure provided by the present invention, such as Figure 1 As shown, the method comprises the following steps: Step 110: When the user asks multiple rounds of questions, the question vector of the first question is sorted based on the ranking retrieval technology of similarity to obtain a first question vector queue; the question vector of the second question is similarly calculated with each vector in the first question vector queue and sorted according to the size of the similarity calculation results to obtain a second question vector queue; the second question is asked by the user later than the first question.
[0023] In this step, the first question vector queue can be determined based on the topic vector corresponding to the first question asked by the user in this question (multiple rounds), or it can be determined based on the topic vector corresponding to a question other than the first question. Similarly, the second question can be the second question after the first question, or it can be other questions after the first question. However, it should be noted that the second question is asked after the first question is asked.
[0024] In this embodiment, in one conversation window, the user can ask multiple rounds of questions; each time the user asks a question, the system first extracts the topic vector of the current question and arranges all question vectors according to a ranking retrieval technology based on similarity to form a queue.
[0025] In this embodiment, the BERTTopic model can be used to extract the corresponding question vector from the current conversation or question content.
[0026] Specifically, the second question vector queue is constructed through the following steps: (1) In a certain conversation window, after the user asks the first question (i.e., the first question), the system uses the BERTTopic model to convert the first question in natural language format into a vector in a high-dimensional space and constructs the first question vector queue in the specified order.
[0027] (2) Add the newly extracted question vector to the first question vector queue, use cosine similarity or other similarity calculation methods to calculate the similarity between the new question vector and the existing vectors in the queue, and sort the vectors in the queue according to the calculated similarity to obtain the second question vector queue, ensuring that the vector most relevant to the current question vector is placed in front.
[0028] Step 120: Perform feature weighting on the second question vector and at least one vector in the second question vector queue that is adjacent to the second question vector to obtain a retrieval vector.
[0029] In this step, for each vector adjacent to the second question vector, the key features of the adjacent vectors (for example, the dimension with the highest weight in the vector) are first extracted to highlight the unique features of each vector; then the features of the input question vector are weighted to increase the weights of features shared with adjacent vectors and reduce the weights of irrelevant features.
[0030] In this embodiment, the second question vector and at least one vector in the second question vector queue adjacent to the second question vector are subjected to feature weighting to obtain a retrieval vector, including: The search vector is calculated using the following formula: ; in, To retrieve the vector, is the second problem vector, is the i-th vector adjacent to the second problem vector, for The feature weights of .
[0031] In this embodiment, It can be dynamically adjusted based on the similarity between neighboring vectors and the input question vector.
[0032] Step 130, search in the cluster of the subject layer of the knowledge base according to the retrieval vector to obtain the target retrieval text for the large answer model to output the answer result; wherein the knowledge base is constructed through a hierarchical cluster index structure and a text online update mechanism; the hierarchical cluster index structure includes a subject layer, a feature layer and a text layer, and each subject vector in the subject layer is anchored to at least one document content vector in the feature layer.
[0033] In this step, the hierarchical cluster index structure is as follows: (1) Topic layer: There are n clusters in the topic layer, each cluster is a cluster, and the cluster contains MinPts topic vectors. The topic vector represents the field or topic to which the document belongs; (2) Feature layer: Contains the feature vector set of the document. Multiple feature vectors in the feature vector set (i.e., document content vectors) represent the key content of the document (including keywords and sentences); the feature vector set is anchored to a certain topic vector in the topic layer; the feature vector can be divided into N clusters according to obvious features; (3) Text layer: Represents the specific text paragraphs or blocks of the document.
[0034] In this embodiment, the document content vector can be extracted through a Latent Dirichlet Allocation (LDA) model.
[0035] In this embodiment, the above-mentioned topic layer, feature layer and text layer can be obtained by performing multiple iterative updates on the sample document data through a clustering algorithm. For example, the topic vector of the sample document is used as a parameter, and these are used to initialize the genetic algorithm (the initialization parameters include the number of topic vectors and the crossover rate). The clustering parameters (including the number of clusters and the distance between clusters) are determined according to the output of the genetic algorithm, and then the topic vectors are sorted by relevance using the clustering parameters and clustered to obtain multiple topic vector clusters of the corresponding main layer; in the same column, the document content vectors extracted from the sample document are sorted by relevance using the same clustering method as the above-mentioned topic clustering, and then clustered to obtain the corresponding feature layer, which includes multiple document content vector clusters.
[0036] In this embodiment, the topic layer includes multiple topic vector clusters, each topic vector includes a cluster core point; searching in the clusters of the topic layer of the knowledge base according to the retrieval vector to obtain the target retrieval text includes: calculating the cosine similarity between the retrieval vector and the cluster core points of each topic vector cluster to obtain multiple similarity calculation results; determining the topic index of the target topic vector cluster according to the maximum value of the multiple similarity calculation results, determining the target document content vector according to the topic index and the anchoring relationship between the topic vector and the document content vector, and determining the target retrieval text according to the target document content vector.
[0037] Specifically, the output retrieval vector is used to search the clusters at the topic layer of the knowledge base (compared with the core points of the cluster by cosine similarity), and the retrieval vector Q and the topic vector D are expressed as: ; The cosine similarity between the retrieval vector Q and the topic vector D can be calculated using the following formula: ; In this embodiment, based on the cosine similarity comparison result between the retrieval vector and the topic vector, the topic index in the topic vector cluster with the highest similarity is selected, the feature vector of the question in the question vector queue is selected, and based on the feature vector clusters anchored with the relevant topics in the topic index, one feature vector is selected for each feature vector cluster, and finally the corresponding input text is obtained based on the feature vector.
[0038] For example, the topic index selects P clusters (within the similarity range), and each cluster selects 1 topic vector; under the selected topic vector node, the feature vectors of the relevant questions in the relevant question vector queue are extracted according to the LDA model, and 3 corresponding feature vector clusters are selected according to the anchoring, and each feature vector cluster selects 1 feature vector to obtain the corresponding input text, and finally inputs the answer model to obtain the corresponding answer result; this method enhances the system's generalization and adaptability when facing different queries by selecting multiple similar topic layer nodes.
[0039] The answer big model retrieval enhancement method based on the hierarchical cluster index structure provided in the embodiment of the present invention sorts the question vector of the first question to obtain a first question vector queue; calculates the similarity between the question vector of the second question and each vector in the first question vector queue and sorts them according to the size of the similarity calculation results to obtain a second question vector queue, then performs feature weighting on the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector, and finally searches the cluster of the subject layer of the knowledge base according to the retrieval vector to obtain the target retrieval text, so as to output the answer result for the answer big model, thereby improving the accuracy and retrieval efficiency of the answer big model when processing complex queries and reducing the "hallucination" phenomenon occurring during the information retrieval process.
[0040] In some embodiments, a knowledge base is constructed by the following steps: extracting a first topic vector and multiple first document content vectors from a document to be input, and determining a first clustering parameter based on the first topic vector; the first clustering parameter includes the number of first clusters and the first inter-cluster distance; calculating the correlation between multiple first document content vectors, and adjusting the sorting of the first topic vector and the initial topic vector based on the correlation to obtain a first topic vector queue, wherein the initial topic vector is obtained based on historical input documents; determining multiple first cluster core points from the first topic vector queue based on the first clustering parameter, and for each first cluster core point, recursively adding neighbor nodes related to the first cluster core point to the same cluster through the first topic vector queue to obtain a topic layer of the knowledge base; wherein the feature layer is based on sequentially calculating, sorting and clustering multiple first document content vectors.
[0041] In this embodiment, the steps of determining the subject layer of the real-time library through document uploading and index construction are as follows: (1) When a document is uploaded to the knowledge base, the vector model is used to extract topic vectors and feature vectors.
[0042] In this embodiment, the topic vector represents the topic of the document, and the feature vector set represents the vectorization of the specific content (keywords / sentences) of the document.
[0043] (2) Determine the number of clusters and the distance between clusters: Use these topic vectors as parameters to initialize the genetic algorithm (the initialization parameters include the number of topic vectors and the crossover rate), and determine the number of clusters MinPts and the distance ε value based on the output of the genetic algorithm.
[0044] (3) Similarity calculation: Use the vector similarity algorithm to calculate the similarity between feature vectors. Then, adjust the topic vectors based on the vector relevance using ranking retrieval technology to generate a topic vector ranking queue.
[0045] (4) Core point confirmation: The determination of clustering core points can be combined with the sorted topic vector queue; for example, if a point has at least MinPts neighboring points within its ε distance, and the similarity between these neighboring points and the point is higher than a certain threshold, then the point can be considered a core point.
[0046] (5) Cluster formation: Based on the core points, clusters are expanded through DBSCAN clustering. For each core point, neighboring points with high similarity are recursively added to the same cluster through the topic vector ranking queue.
[0047] In this embodiment, for boundary points (those with no neighbor points within their ε distance), a single cluster can be formed.
[0048] In this embodiment, the vector clusters in the feature layer can be obtained by sequentially calculating, sorting and clustering the vector correlation of the plurality of first document content vectors, as described in the above steps (1) to (5), which will not be described in detail in this embodiment.
[0049] In this embodiment, the vector clusters in the text layer can be obtained by sequentially performing vector correlation calculation, sorting and clustering on specific text paragraphs or blocks of the document to be input, as described in the above steps (1)-(5), which will not be repeated in this embodiment.
[0050] The answer large model retrieval enhancement method based on a hierarchical cluster index structure provided in an embodiment of the present invention extracts multiple first topic vectors and multiple first document content vectors from the input document, determines corresponding clustering parameters according to the corresponding vectors, and sequentially performs vector correlation calculation, sorting and clustering to obtain the topic layer and feature layer of the knowledge base. By using a vector model and a hierarchical cluster index structure, the retrieval speed is accelerated, and the user's query intent and content can be accurately reflected, thereby improving the system's ability to process large amounts of data.
[0051] In some embodiments, the knowledge base is updated online through the following steps: when a new input document is added to the knowledge base, a second topic vector and multiple second document content vectors are extracted from the new input document; a second clustering parameter is determined based on the second topic vector; the second clustering parameter includes the number of second clusters and the distance between second clusters; the second topic vector is merged into the first topic vector queue based on a similarity ranking retrieval technique to obtain a second topic vector queue; multiple second cluster core points are determined from the second topic vector queue based on the second clustering parameter, and for each second cluster core point, neighbor nodes related to the second cluster core point are recursively added to the same cluster through the second topic vector queue to obtain an updated topic layer of the knowledge base; wherein each topic vector in the updated topic layer is anchored to at least one document content vector in the updated feature layer; the updated feature layer is based on vector correlation calculation, queue update, sorting and cluster acquisition of multiple second document content vectors in sequence.
[0052] In this embodiment, when a new document is added to the knowledge base, the genetic algorithm is first updated and the new cluster number MinPts and the distance ε value are determined; then the newly added topic vector is inserted into the original queue according to the sorting retrieval algorithm; then the topic vector is characterized (described in the next sub-point), and finally, according to DBSCAN clustering, when the similarity of the topic vector with a core point is greater than a certain threshold and within its ε distance, the document topic vector is aggregated into the appropriate cluster; the specific steps are as follows: (1) Document preprocessing: Before extracting a plurality of second topic vectors and a plurality of second document content vectors from a new input document, the method includes: performing cleaning and preprocessing operations on the new input document to obtain a processed document; wherein the preprocessing includes word segmentation and removal of stop words and punctuation marks.
[0053] (2) Vector embedding: The BERTTopic model algorithm automatically detects topics in the text and generates embedded topic vectors.
[0054] (3) Update the genetic algorithm and determine the new number of clusters MinPts and the distance ε value. Insert the newly added topic vector into the original queue according to the sorting retrieval algorithm, and update the existing topic feature vector set (within the cluster) on this basis to maintain the differentiation between the nodes of the feature topic vector set within the cluster.
[0055] (4) Perform a weighted synthesis of the existing topic vector and the topic vector of the new document to reflect the impact of the new document. Then execute the following weighted synthesis formula to update the topic vector: ; Among them, T newis the updated topic vector, Texisting is the existing topic vector, and Tnew_doc is the topic vector of the new document. α is a weight factor between 0 and 1, α Used to balance the contribution of existing topic vectors and new document topic vectors.
[0056] (5) Finally, based on DBSCAN clustering, the topic vectors are aggregated into a suitable cluster.
[0057] In this embodiment, for a knowledge base to which a new document's topic vector is added, it is necessary to update the existing topic vectors in the knowledge base to maintain the differentiation between topic vector points within a cluster; the specific update rules are as follows: (1) Document preprocessing: Clean and preprocess new documents, including word segmentation, removal of stop words and punctuation marks, etc., to construct text data suitable for feature extraction.
[0058] (2) Topic vector difference detection: First, it is necessary to quantitatively analyze the difference between two feature vector sets within a certain range of the vector queue; this is achieved by calculating the cosine similarity between the two vector sets.
[0059] (3) New topic vector generation: Based on the topic vector of the new document, a new feature vector set is created according to the LDA model to reflect the unique information of the new document. In the feature set node, in order to further highlight the characteristics of each feature vector, each feature in the vector set can be weighted, especially those features with significant differences between the two vector set features. The feature weighting formula is as follows: F i,updated = w i⋅ (F i,existing +ΔF i,new_doc ); in, w i For the i The weight of each feature, ΔF i,new_doc is the first i The difference between the feature and the corresponding feature in the existing vector set; F i,updated is the weighted document vector set.
[0060] (4) Iterative optimization: Regularization techniques are used to iterate, and each iteration re-evaluates the differences between feature vector sets and adjusts the weights until a satisfactory level of differentiation is achieved.
[0061] (5) The feature vector set is clustered according to the above topic vector clustering steps; it should be noted that clustering should ensure feature differentiation as much as possible and the feature similarity within the cluster is within the specified range.
[0062] The answer large model retrieval enhancement method based on the hierarchical cluster index structure provided in the embodiment of the present invention updates the subject layer and feature layer in the knowledge base according to the new input document when a new input document is added to the knowledge base. The incremental update and differential update strategies enable the index to adapt to the addition of new documents and maintain the timeliness and accuracy of the information. At the same time, by distinguishing between different versions of documents and topics, the confusion between new and old document information is reduced, avoiding inconsistent content in the retrieval results.
[0063] The following describes the response large model retrieval enhancement device based on a hierarchical cluster index structure provided by the present invention. The response large model retrieval enhancement device based on a hierarchical cluster index structure described below and the response large model retrieval enhancement method based on a hierarchical cluster index structure described above can be referenced to each other.
[0064] Figure 2 Schematic diagram of the structure of the answer large model retrieval enhancement device based on the hierarchical cluster index structure provided by the present invention. Figure 2 As shown, the answer large model retrieval enhancement method device based on the hierarchical cluster index structure includes: a queue acquisition module 210, a vector weighting module 220 and a retrieval module 230.
[0065] The queue acquisition module 210 is used to sort the question vectors of the first question based on the ranking retrieval technology of similarity to obtain a first question vector queue when the user asks multiple rounds of questions; calculate the similarity between the question vector of the second question and each vector in the first question vector queue and sort them according to the size of the similarity calculation results to obtain a second question vector queue; the second question is asked by the user later than the first question; A vector weighting module 220, configured to perform feature weighting on the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector; The retrieval module 230 is used to search in the cluster of the subject layer of the knowledge base according to the retrieval vector to obtain the target retrieval text so as to output the answer result for the large answer model; wherein the knowledge base is constructed through a hierarchical cluster index structure and a text online update mechanism; the hierarchical cluster index structure includes a subject layer, a feature layer and a text layer, and each subject vector in the subject layer is anchored to at least one document content vector in the feature layer.
[0066] The answer big model retrieval enhancement device based on the hierarchical cluster index structure provided in the embodiment of the present invention obtains a first question vector queue by sorting the question vector of the first question; calculates the similarity between the question vector of the second question and each vector in the first question vector queue and sorts them according to the size of the similarity calculation results to obtain a second question vector queue, then performs feature weighting on the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector, and finally searches the cluster of the subject layer of the knowledge base according to the retrieval vector to obtain the target retrieval text, so as to output the answer result for the answer big model, thereby improving the accuracy and retrieval efficiency of the answer big model when processing complex queries and reducing the "hallucination" phenomenon occurring during the information retrieval process.
[0067] Figure 3 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 3 As shown, the electronic device may include: a processor 310 , a communications interface 320 , a memory 330 and a communication bus 340 , wherein the processor 310 , the communications interface 320 , and the memory 330 communicate with each other via the communication bus 340 . The processor 310 can call the logic instructions in the memory 330 to execute the answer big model retrieval enhancement method based on the hierarchical cluster index structure, the method comprising: in the case where the user asks multiple rounds of questions, sorting the question vector of the first question based on the similarity ranking retrieval technology to obtain a first question vector queue; calculating the similarity between the question vector of the second question and each vector in the first question vector queue and sorting them according to the size of the similarity calculation result to obtain a second question vector queue; the second question is asked by the user later than the first question; feature weighting the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector; searching in the cluster of the subject layer of the knowledge base according to the retrieval vector to obtain the target retrieval text for the answer big model to output the answer result; wherein the knowledge base is constructed by a hierarchical cluster index structure and a text online update mechanism; the hierarchical cluster index structure includes a subject layer, a feature layer and a text layer, and each subject vector in the subject layer is anchored to at least one document content vector in the feature layer.
[0068] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0069] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the answer large model retrieval enhancement method based on the hierarchical cluster index structure provided by the above methods, the method including: when the user asks multiple rounds of questions, sorting the question vector of the first question based on the ranking retrieval technology of similarity to obtain a first question vector queue; calculating the similarity between the question vector of the second question and each vector in the first question vector queue and sorting them according to the size of the similarity calculation result to obtain a second question vector queue; the second question is asked by the user later than the first question; feature weighting the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector; searching in the cluster of the subject layer of the knowledge base according to the retrieval vector to obtain the target retrieval text, so as to output the answer result for the answer large model; wherein the knowledge base is constructed by a hierarchical cluster index structure and a text online update mechanism; the hierarchical cluster index structure includes a subject layer, a feature layer and a text layer, and each subject vector in the subject layer is anchored to at least one document content vector in the feature layer.
[0070] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the answer large model retrieval enhancement method based on a hierarchical cluster index structure provided by the above-mentioned methods, the method comprising: in the case where a user asks multiple rounds of questions, sorting the question vector of the first question based on a ranking retrieval technology based on similarity to obtain a first question vector queue; calculating the similarity between the question vector of the second question and each vector in the first question vector queue and sorting them according to the size of the similarity calculation results to obtain a second question vector queue; the second question is asked by the user later than the first question; feature weighting the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector; searching in the cluster of the subject layer of the knowledge base according to the retrieval vector to obtain a target retrieval text for the answer large model to output an answer result; wherein the knowledge base is constructed through a hierarchical cluster index structure and a text online update mechanism; the hierarchical cluster index structure includes a subject layer, a feature layer and a text layer, and each subject vector in the subject layer is anchored to at least one document content vector in the feature layer.
[0071] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0072] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for enhancing the retrieval of a large answer model based on a hierarchical cluster index structure, characterized in that: include: When the user asks multiple rounds of questions, the question vectors of the first question are sorted based on the ranking retrieval technology of similarity to obtain a first question vector queue; Calculate the similarity between the question vector of the second question and each vector in the first question vector queue and sort them according to the similarity calculation results to obtain a second question vector queue; The second question is asked by the user later than the first question; Perform feature weighting on the second question vector and at least one vector in the second question vector queue that is adjacent to the second question vector to obtain a retrieval vector; According to the retrieval vector, a search is performed in the cluster of the subject layer of the knowledge base to obtain the target retrieval text, so as to supply the answer model with an answer result; wherein, the knowledge base is constructed by a hierarchical cluster index structure and a text online update mechanism; the hierarchical cluster index structure includes a subject layer, a feature layer and a text layer, and each subject vector in the subject layer is anchored to at least one document content vector in the feature layer.
2. The method for enhancing the retrieval of a large answer model based on a hierarchical cluster index structure according to claim 1, characterized in that: The knowledge base is constructed through the following steps: Extracting a first topic vector and a plurality of first document content vectors from the document to be input, and determining a first clustering parameter according to the first topic vector; the first clustering parameter includes a first cluster number and a first inter-cluster distance; Calculating the correlation between the plurality of first document content vectors, and adjusting the order of the first topic vectors and the initial topic vectors according to the correlation to obtain a first topic vector queue, wherein the initial topic vector is obtained based on a historical input document; Determine multiple first cluster core points from the first topic vector queue according to the first cluster parameter, and for each first cluster core point, recursively add neighbor nodes related to the first cluster core point to the same cluster through the first topic vector queue to obtain a topic layer of the knowledge base; The feature layer is based on sequentially calculating, sorting and clustering the vector correlation of the plurality of first document content vectors.
3. The method for enhancing the retrieval of a large answer model based on a hierarchical cluster index structure according to claim 2, characterized in that: The knowledge base is updated online through the following steps: In the case where a new input document is created in the knowledge base, extracting a second topic vector and a plurality of second document content vectors from the new input document; Determining a second clustering parameter according to the second topic vector; the second clustering parameter includes a second cluster number and a second inter-cluster distance; The second topic vector is merged into the first topic vector queue based on the ranking retrieval technology of similarity to obtain a second topic vector queue; Determine a plurality of second cluster core points from the second topic vector queue according to the second cluster parameter, and for each second cluster core point, recursively add neighbor nodes related to the second cluster core point to the same cluster through the second topic vector queue to obtain an updated topic layer of the knowledge base; Among them, each topic vector in the updated topic layer is anchored to at least one document content vector in the updated feature layer; the updated feature layer is based on vector correlation calculation, queue update, sorting and clustering acquisition of the multiple second document content vectors in sequence.
4. The method for enhancing the retrieval of a large answer model based on a hierarchical cluster index structure according to claim 3 is characterized in that: Before extracting a plurality of second topic vectors and a plurality of second document content vectors from the new input document, the method comprises: The new input document is cleaned and preprocessed to obtain a processed document; wherein the preprocessing includes word segmentation, and removal of stop words and punctuation marks.
5. The method for enhancing the retrieval of a large answer model based on a hierarchical cluster index structure according to claim 1, characterized in that: The topic layer includes a plurality of topic vector clusters, each of which includes a cluster core point; The searching in the clusters of the subject layer of the knowledge base according to the search vector to obtain the target search text comprises: Calculating the cosine similarity between the search vector and the cluster core points of each topic vector cluster to obtain multiple similarity calculation results; The topic index of the target topic vector cluster is determined according to the maximum value among the multiple similarity calculation results, the target document content vector is determined according to the topic index and the anchoring relationship between the topic vector and the document content vector, and the target retrieval text is determined according to the target document content vector.
6. The method for enhancing the retrieval of a large answer model based on a hierarchical cluster index structure according to claim 1, characterized in that: The step of performing feature weighting on the second question vector and at least one vector in the second question vector queue adjacent to the second question vector to obtain a retrieval vector comprises: The search vector is calculated using the following formula: ; Among them, the is the search vector, is the second problem vector, is the i-th vector adjacent to the second problem vector, for The feature weights of .
7. A method and device for enhancing retrieval of a large answer model based on a hierarchical cluster index structure, characterized in that: include: A queue acquisition module is used to sort the question vectors of the first question based on the ranking retrieval technology of similarity to obtain a first question vector queue when the user asks multiple rounds of questions; calculate the similarity between the question vector of the second question and each vector in the first question vector queue and sort them according to the size of the similarity calculation results to obtain a second question vector queue; The second question is asked by the user later than the first question; a vector weighting module, configured to perform feature weighting on the second question vector and at least one vector adjacent to the second question vector in the second question vector queue to obtain a retrieval vector; A retrieval module is used to search in the cluster of the subject layer of the knowledge base according to the retrieval vector to obtain the target retrieval text so as to supply the answer model with the answer result; wherein, the knowledge base is constructed by a hierarchical cluster index structure and a text online update mechanism; the hierarchical cluster index structure includes a subject layer, a feature layer and a text layer, and each subject vector in the subject layer is anchored with at least one document content vector in the feature layer.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for enhancing the retrieval of a large answer model based on a hierarchical cluster index structure as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the answer large model retrieval enhancement method based on a hierarchical cluster index structure as described in any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the answer large model retrieval enhancement method based on a hierarchical cluster index structure as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Question and answer method, device and equipment and storage medium
CN111782767A
Government affair service field multi-strategy fusion dialogue method based on knowledge graph
CN116628172A
Large-model multi-round dialogue method, system and equipment based on aggregation retrieval enhancement
CN117290491A
Multi-round dialogue method and device, equipment and storage medium
CN117669597A
Knowledge retrieval enhancement-based large language model question and answer method and device
CN118113836A
Cited By
Data query method and system based on large model platform
CN120429433A
A data query method and system based on large model platform
CN120429433B
Large model retrieval enhancement generation method based on index structure optimization
CN121388071A
An index structure optimization-based large model retrieval enhanced generation method
CN121388071B