A knowledge question and answer high relevance recommendation method based on large model semantic enhancement
By optimizing the construction process of the HNSW graph and introducing domain-specific topic differences and key limiting information differences indicators, the problem of misleading connections in existing technologies is solved, enabling efficient and accurate recommendation of relevant questions in the knowledge question answering system.
Patent Information
- Application Number
- CN202511005496.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-22
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-07-22
AI Technical Summary
Existing knowledge-based question-answering systems, in professional fields, suffer from misleading connections in their index graph construction based on the HNSW algorithm. This results in insufficient accuracy and efficiency in recommending relevant questions, failing to meet users' professional and refined needs.
By optimizing the construction process of the HNSW graph, introducing domain-specific differences and key constraint information differences, and adjusting the Euclidean distance, an optimized HNSW graph is constructed, reducing misleading connections and improving the accuracy and efficiency of ANN search.
This improves the quality and user experience of relevant question recommendations in the knowledge question answering system, ensuring that the recommendation results are highly relevant to users' professional and refined needs.
Smart Images

Figure CN120873177B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of knowledge question answering technology, and in particular to a highly relevant recommendation method for knowledge question answering based on large model semantic enhancement. Background Technology
[0002] In modern knowledge question answering systems, to enhance user experience and support the spirit of deep learning, related questions are usually recommended after answering the user's current question. The main methods to achieve this function include: first, using a large language model (LLM) to transform the user's question and the questions in the knowledge base into high-dimensional semantic vectors, that is, embedding vectors; then, using an approximate nearest neighbor (ANN) search algorithm, such as the hierarchical navigable small world graph (HNSW) algorithm, to efficiently recall candidate questions that are semantically geometrically close to the user's current question from a large-scale question embedding vector library.
[0003] The HNSW algorithm constructs a multi-layer graph index, establishes connections between nodes based on Euclidean distance, and performs fast lookups. However, when constructing the graph index, the HNSW algorithm relies entirely on the original geometric distance between the semantic vectors corresponding to the questions. Although the embedding vectors generated by the generalized large language model can capture generalized semantics, their ability to distinguish semantic substantive differences caused by subtle but crucial "contextual specificity" (such as specific groups of people, applicable conditions) or "core question limiting information" (such as negation words, numerical constraints) within specialized domains is limited. This inherently limits the methods of candidate question recall relying on algorithms such as HNSW and ANN in highly specialized fields with high knowledge precision requirements (such as medicine, law, and finance). Furthermore, the general embedding vectors themselves do not directly contain structured domain ontology knowledge (such as concept hierarchy, mutual exclusion relationships, etc.), and this deep semantic information is easily averaged or ignored during embedding vector generation. Therefore, when the "pure geometric distance dependency" graph construction mechanism of the HNSW algorithm is applied to such general embedding vectors, it results in some "misleading connections" in the constructed graph index that do not correspond to the actual knowledge in the professional field. These connections only reflect superficial or generalized semantic similarities, but may mask deep professional logical differences. This affects the accuracy and efficiency of the search path of ANN search based on this graph index when faced with user queries with clear professional context or key constraints. It is difficult to reliably and efficiently navigate to the question nodes that are truly highly matched with the user's deep professional needs. Ultimately, this limits the accuracy, professional relevance, and ability to meet the segmented needs of users in the knowledge question answering system. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a highly relevant recommendation method for knowledge question answering based on large model semantic enhancement to solve the problem of xx.
[0005] This invention provides a highly relevant knowledge-based question-answering recommendation method based on large-model semantic enhancement, which includes the following steps:
[0006] Obtain the query question submitted by the user, and use a large language model to transform the query question into a query semantic vector;
[0007] The process of constructing the index graph of the question vector library using the HNSW algorithm is optimized to obtain an optimized HNSW graph. The question vector library is constructed by converting all questions in the knowledge base into question vectors using a large language model.
[0008] An ANN search is performed in the optimized HNSW graph to obtain questions that are highly relevant to the query semantic vector, which are then used to recommend and provide feedback to the user.
[0009] The optimized method for obtaining the HNSW graph is as follows:
[0010] For any two question vectors in the question vector library, obtain the Euclidean distance between the two question vectors, perform domain topic identification on the two question vectors to obtain the domain topic difference index between the two question vectors, and perform initial optimization on the Euclidean distance based on the domain topic difference index to obtain the optimized Euclidean distance;
[0011] Extract the key constraint information of any two problem vectors to obtain the key constraint information difference index between any two problem vectors. Use the key constraint information difference index to optimize the optimized Euclidean distance again to obtain the final effective distance between any two problem vectors.
[0012] Obtain the final effective distance between every two problem vectors in the problem vector library, and construct the optimized HNSW graph based on the final effective distance.
[0013] The beneficial effects of the embodiments of the present invention compared with the prior art are as follows:
[0014] In the process of constructing the index graph using the HNSW algorithm in a knowledge question answering system, the distance metric used for neighbor selection is optimized by incorporating an understanding of professional domain knowledge (i.e., domain topic difference index) and consideration of the consistency of key constraint information of the question (i.e., key constraint information difference index). This allows the generated graph structure to better reflect the inherent connections of domain knowledge, reducing misleading connections caused by simply relying on generalized semantic similarity. Consequently, in the subsequent ANN search process, it can more accurately and efficiently navigate to results that are truly highly relevant to the user's professional and refined needs, ultimately improving the overall quality of relevant question recommendations and user experience in the knowledge question answering system. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a flowchart of a highly relevant recommendation method for knowledge question answering based on large model semantic enhancement, provided in Embodiment 1 of the present invention. Detailed Implementation
[0017] Embodiments of this disclosure are described in detail below, with examples of these embodiments illustrated in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this disclosure, and should not be construed as limiting it.
[0018] It should be noted that the terms "first," "second," etc., used in this disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure.
[0019] To illustrate the technical solution of the present invention, specific embodiments are described below.
[0020] See Figure 1 This is a flowchart of a highly relevant recommendation method for knowledge question answering based on large-model semantic enhancement, provided in Embodiment 1 of the present invention. Figure 1 As shown, the method may include:
[0021] Step S101: Obtain the query question submitted by the user, and use a large language model to transform the query question into a query semantic vector.
[0022] The function of existing knowledge question-answering systems is to receive user-inputted questions, answer them, and simultaneously recommend related questions to gain a deeper understanding of the user's needs. Therefore, in this embodiment of the invention, the construction method for a knowledge question-answering system in any professional field (such as medicine, industry, finance, etc.) is roughly as follows:
[0023] (1) Preparation of problem text data
[0024] A knowledge base is constructed by collecting a large number of questions and their corresponding answer texts in a professional field. These questions and answer texts can come from professional Q&A communities, online courses, textbooks, field literature, or related knowledge bases. The collected raw question texts are cleaned, removing irrelevant characters and standardizing formatting, and each question is assigned a unique identifier.
[0025] (2) Preparation of the large language model
[0026] Choose a pre-trained large language model, which can be an open-source general-purpose large model (such as Deepseek-r1) or a commercial large model (Claude, GPT, Gemini, etc.) to ensure that these LLMs can be called through APIs or other means for text feature extraction and semantic judgment.
[0027] (3) Preparation and configuration of the text embedding model (Sentence-BERT)
[0028] The Sentence-BERT model was chosen as the core tool for converting question text into high-dimensional semantic vectors. This model generates fixed-dimensional embedding vectors for input sentences, phrases, or paragraphs, which can be directly used for semantic similarity comparison. In specific professional domain applications, to further enhance the representational ability of the embedding vectors to the domain's semantics, the Sentence-BERT model, which has been adaptively fine-tuned on the corpus of that professional domain, was prioritized. The loading and calling interface of the Sentence-BERT model was configured to ensure its stable generation of semantic vectors for input question text fragments.
[0029] (4) After the above data preparation is completed, all question texts in the knowledge base are converted into high-dimensional semantic vectors, i.e. question vectors, using the configured Sentence-BERT model, and then a question vector library is formed. Then, the HNSW algorithm is used to construct an index graph, i.e., the HNSW graph, for use by ANN search. After the knowledge question answering system receives the question input by the user, it can efficiently feed back candidate questions that are geometrically close to the user's current question in the question vector library.
[0030] Therefore, after constructing the knowledge question answering system, when the system receives a user's query, it uses a large language model to transform the query into a high-dimensional semantic vector, which is then recorded as the query semantic vector. Then, in a conventional approach, questions highly relevant to the query semantic vector can be obtained through an ANN search based on the HNSW graph constructed in the knowledge question system. However, in the conventional approach, when constructing the index graph of the question vector library using the HNSW algorithm, it relies entirely on the original geometric distance between the semantic vectors corresponding to the questions. Although the embedding vectors generated by the generalized large language model can capture the generalized semantics of the question, its ability to distinguish whether different questions are truly aligned at the core conceptual level of a professional field is limited. For example, consider the following two questions in the field of physics: "Briefly describe the content of Newton's second law and its application in the analysis of macroscopic low-speed object motion" and "How to describe the deflection of light near a massive celestial body within the framework of general relativity?" These two problems inevitably share common terms widely used in physics, such as "laws," "objects," "motion," "analysis," and "phenomena." The embedding vectors generated by the general language model will exhibit similarity in representing these shared semantic dimensions. This results in the overall embedding vectors having a significantly smaller geometric distance than the substantial theoretical differences they should reflect within the framework of specialized physics knowledge. From a specialized physics perspective, the former belongs to classical mechanics, with core concepts like Newton's laws and macroscopic low speeds; the latter belongs to general relativity, with core concepts like spacetime curvature, light deflection, and massive celestial bodies. They differ fundamentally in their basic theoretical framework, scope of application, and core physical concepts. If the HNSW algorithm treats these problems as close neighbors and establishes connections based solely on raw geometric distance, the constructed index graph will contain some misleading connections with low logical relevance or that should be clearly distinguished. In subsequent ANN searches, these connections have a high probability of misleading users into discussions about the application of Newton's laws when a user queries a question about the calculation of light deflection in general relativity. This reduces the accuracy and efficiency of the search, and consequently fails to meet the user's need for precise retrieval of specialized knowledge.
[0031] Therefore, in this embodiment of the invention, before obtaining questions with high relevance to the query semantic vector through ANN search based on the HNSW graph constructed in the knowledge question system, the process of constructing the index graph of the question vector library using the HNSW algorithm is optimized to better reflect the inherent correlation of domain knowledge and reduce misleading connections caused by simply relying on generalized semantic similarity.
[0032] Step S102: Optimize the process of constructing the index graph of the problem vector library using the HNSW algorithm to obtain the optimized HNSW graph.
[0033] Because the HNSW algorithm relies entirely on the geometric distance between the original semantic vectors when constructing the index graph, and general semantic embedding vectors have limitations in expressing deep semantic constraints, key limiting information, and inherent knowledge structures within a professional domain, some "misleading connections" are formed in the HNSW graph that do not correspond to actual knowledge in the professional domain. This negatively impacts the accuracy and efficiency of ANN searches based on this graph when faced with user queries with clear professional context or key limiting conditions. It becomes difficult to reliably and efficiently navigate to question nodes that truly match the user's deep professional needs, ultimately limiting the accuracy, professional relevance, and ability to meet the segmented needs of users in the knowledge question answering system. Therefore, this invention optimizes the geometric distance between semantic vectors when constructing the index graph to obtain a domain-enhanced HNSW graph, i.e., an optimized HNSW graph. The method for constructing the domain-enhanced HNSW graph is as follows:
[0034] For any two question vectors in the question vector library, let them be denoted as and First, the Euclidean distance between any two problem vectors is obtained by calculating the L2 norm between them. This is essentially a simple geometric distance. Then, to further enhance domain characteristics, in this embodiment of the invention, a consistency assessment of the core professional domain theme is performed on any two question vectors, thereby adjusting and optimizing the Euclidean distance between them. This involves identifying the domain theme of any two question vectors to obtain a domain theme difference index between them. Based on this domain theme difference index, the Euclidean distance is initially optimized to obtain an optimized Euclidean distance.
[0035] Specifically, the LLM large-scale model is used to identify and extract domain topic words or core phrases from the question text of any question vector, obtaining at least one domain topic word. This domain topic word represents indicative words or phrases representing the core professional field. Then, the Sentence-BERT model is used to convert each domain topic word into a corresponding semantic vector. All semantic vectors are then average-pooled to obtain an aggregate vector, which is used to quantify the semantic differences of each question vector. The calculation method for the aggregate vector is as follows:
[0036]
[0037]
[0038] in, Represents the problem vector The corresponding aggregate vector, Represents the problem vector The number of corresponding domain keywords Represents the problem vector The semantic vector of the corresponding i-th domain topic word, Represents the problem vector The corresponding aggregate vector, Represents the problem vector The number of corresponding domain keywords Represents the problem vector The semantic vector of the j-th domain topic word.
[0039] Furthermore, the cosine similarity between the aggregated vectors of each of any two question vectors is obtained, and the difference between the constant 1 and the cosine similarity is calculated. This difference, representing a preset proportion, is recorded as the domain-topic difference index between any two question vectors. The formula for calculating the domain-topic difference index between any two question vectors is as follows:
[0040]
[0041] in, This represents the domain-topic dissimilarity index between any two question vectors, where 1 indicates a constant. Represents the problem vector The corresponding aggregate vector, Represents the problem vector The corresponding aggregate vector, This represents a function that calculates the cosine similarity between two vectors.
[0042] It's important to note that aggregated vectors represent the overall semantic direction of each question vector. After obtaining the aggregated vector for each question vector, the degree of dissimilarity between these two aggregated semantic vectors is evaluated. If the two aggregated semantic vectors are highly consistent in direction, it indicates that they represent very similar topics, and their dissimilarity is low. Conversely, if the directions differ greatly or even are opposite, it indicates significant topic differences, and the dissimilarity is high. This degree of dissimilarity is quantified as a value between 0 and 1, which is the domain topic difference index. Its value ranges from 0 to 1, where 0 indicates that the two question vectors are semantically judged to be highly consistent (i.e., the domain topic inconsistency is zero), while 1 indicates that they are semantically judged to be highly inconsistent and belong to completely different domain topics, which is the domain topic difference index. The larger the value, the greater the difference between the two problem vectors in the core professional field.
[0043] Furthermore, based on the aforementioned domain-specific differences index Euclidean distance between any two problem vectors The initial optimization is performed to obtain the optimized Euclidean distance: the preset domain topic inconsistency weight coefficient is obtained, the product of the domain topic inconsistency weight coefficient and the domain topic difference index is calculated, the sum of the product and the constant 1 is used as the initial optimization coefficient of the distance, and the product between the Euclidean distance and the initial optimization coefficient of the distance is used as the optimized Euclidean distance.
[0044] The formula for calculating the optimized Euclidean distance is as follows:
[0045]
[0046] in, This represents the optimized Euclidean distance between any two problem vectors. This represents the Euclidean distance between any two problem vectors, where 1 represents a constant. This represents the weighting coefficient for inconsistency between domain and topic. This represents an index of domain-topic dissimilarity between any two question vectors.
[0047] It should be noted that, The value is set to 0.5. This specific value can be optimized in a specific field based on experimental data to obtain the best results, and no restrictions are imposed here. Standard HNSW diagrams rely solely on L2 distance, but L2 distance cannot accurately reflect whether two problems belong to the same fine-grained specialty branch, which can lead to improper connections between problems from different specialty branches. This invention, by introducing... This is used to quantify domain-specific inconsistency, which stems directly from real-time semantic analysis and domain attribution determination of the question text. When the LLM model determines... and When the core professional fields and themes are highly consistent, Approaching 0, at this point, The value approaches 1. Approximately equal to the original L2 distance, that is This indicates that the similarity of the original embedding vectors is trusted in this case; when the LLM model judges... and When their core areas of expertise differ significantly (for example, one is about superconductivity in condensed matter physics, and the other is about the Standard Model in particle physics), their... (It will get a higher value) The value will be greater than 1, thus amplifying the original L2 distance to amplify cases where the core professional domains are inconsistent but the original semantics are similar.
[0048] The embodiments of the present invention introduce This means that when selecting neighbors, the HNSW algorithm may fail to select neighbors even if the original embedding vectors for some problems are geometrically similar, if their subject matter is judged to be significantly different by the LLM model. This is due to the increased [potential for a problem to fail]. Alignment at the macro-level reduces the probability of being connected, thus resolving misleading connections caused by the inability to distinguish between macro-domain themes and ensuring that the issues considered for connection have basic consistency within their respective large knowledge domains or theoretical frameworks. However, alignment at the macro-level alone cannot completely solve all misleading connection problems, especially in professional knowledge question-answering scenarios with extremely high matching accuracy requirements. It is a fact that many professional questions, even those with the same macro-level theme or theoretical branch, can have fundamentally different core semantics, scope of application, and solution paths due to subtle but crucial differences in the text's defining information. These defining information are core elements that define specific problem scenarios, constrain solution conditions, and directly affect the validity of the answer. They typically manifest as specific parameter values or their ranges, specific pre-assumptions or boundary conditions, specific states of the operating environment, and the specific sub-object or sub-context targeted by the question.
[0049] For example: In any professional field, the problem vector and problem vector All discussions revolve around the same core theory or technology (for example, in the engineering field, they all involve "fatigue life prediction of specific alloy materials," or in the computer science field, they all explore "implementation and optimization of the quicksort algorithm"), thus passing the above-mentioned macro-theme alignment test. The value is low, but the problem vector It explicitly includes one or more specific constraints (e.g., It is "a fatigue life prediction model for this specific alloy material under periodic high-frequency vibration loads and corrosive environments", or It refers to "a non-recursive optimized implementation of the quicksort algorithm for input arrays containing a large number of duplicate elements," while the problem vector... This discussion focuses on the application of the theory or technique under general or idealized conditions (e.g., problem vectors). The two questions are "fatigue life of a specific alloy material under standard static load" and "standard recursive implementation of the quicksort algorithm and its average time complexity." Although their macro-themes ("alloy fatigue life" or "quicksort") are consistent, the significant differences in these key limiting information (such as "periodic high-frequency vibration load and corrosive environment" and "non-recursive optimization of input arrays with a large number of repeating elements") mean that these two problem vectors actually correspond to completely different specific problem situations, employing different analytical models, computational methods, and even focusing on different performance indicators, leading to differentiated conclusions.
[0050] Therefore, if the HNSW algorithm is only based on Optimizing the Euclidean distance can lead to situations where two question vectors, while sharing a similar macro-topic, are tightly linked due to mismatched key constraints. Consequently, when a user submits a precise query containing these specific constraints, the HNSW search path is highly likely to be incorrectly guided to neighboring question nodes discussing general scenarios or other irrelevant constraints due to these improper connections. This bias results in a final list of recommended questions that, while seemingly related in macro-topic terms, misalign with the user's true intent in terms of specific problem scenarios, solution constraints, and detailed requirements, thus reducing the accuracy of the recommendation results. Therefore, this invention, building upon optimization of macro-domain concept alignment, further considers the consistency of key constraints between question vectors at a micro-level, thereby re-optimizing the Euclidean distance between any two question vectors to obtain the final effective distance between them.
[0051] Specifically, for any one of any two problem vectors... Using a large language model, at least one key limiting information is extracted from the question text of any given question vector, denoted as... ,in, It is the number of key limiting information extracted; for Each key qualifying information in Calculate its relationship with the problem vector Semantic conflict scoring between problem texts Its value range is [0, 1]. In this embodiment, the semantic conflict score... This is achieved by using a large language model for judgment. Specifically, the process involves constructing a model containing key qualifying information. and problem vector The prompt text is given to the LLM model, which is asked to evaluate whether there is a conflict or significant inconsistency between the two. This embodiment is designed with the following prompt: "A given constraint is: {" The content}, now there is a question: {problem vector} Please read and judge carefully whether the content of this question clearly conflicts with the given constraints or shows significant inconsistency in the core constraints. If there is a serious conflict or complete inconsistency, please score 1; if there is no conflict and it is completely consistent or compatible, please score 0; if there is some inconsistency but not a serious conflict, please give a corresponding score between 0 and 1. The LLM model analyzes key constraint information based on its understanding of natural language and background knowledge. and problem vector The question asks for the semantic relationships between the text and outputs a numerical value between 0 and 1. Among them, a semantic conflict score of 0 means key qualifying information. and problem vector The question text is fully compatible or identical; a semantic conflict score of 1 indicates key qualifying information. and problem vector The question texts contain serious conflicts or are completely contradictory. Therefore, using a large language model, it is possible to obtain each of the aforementioned key limiting information and the other question vector from any two question vectors. The semantic conflict score between the question texts is used to determine the maximum semantic conflict score as the question vector. Overall semantic conflict score , This represents the function that takes the maximum value.
[0052] It should be noted that when using the LLM model to obtain the semantic conflict score of any key limiting information, the statistical volatility that may exist in the LLM model output is taken into account. Although the precise value of the LLM model output may vary due to subtle changes in its internal mechanism or prompts, the embodiments of the present invention mainly rely on the excellent ability of the LLM model to accurately capture and quantify the core judgment signal of whether there is a significant semantic conflict from complex natural language text. In order to ensure the stability and reliability of this judgment, the embodiments of the present invention emphasize the use of mature prompting engineering technology and standardized prompts containing clear instructions to guide the LLM model to produce more consistent output.
[0053] Similarly, obtain any problem vector Overall semantic conflict score Furthermore, based on the overall semantic conflict score of each of any two question vectors, a key constraint information difference index is obtained between any two question vectors: the maximum value among the overall semantic conflict scores of each of any two question vectors is taken as the key constraint information difference index between any two question vectors. .
[0054] It should be noted that in professional knowledge question-answering scenarios, when a candidate question significantly conflicts with any key constraint of the user's question, regardless of how well other key constraints match, the overall relevance of the candidate question will be greatly reduced. This is because it may directly lead to the provided answer or information being inapplicable or even incorrect in terms of key constraints. Therefore, to maintain high sensitivity to such conflicts and effectively distinguish candidate questions with at least one serious inconsistency in key constraints, a maximum semantic conflict score is selected using a maximum value function to represent that as long as there is a serious conflict in one key constraint, the overall conflict degree is high. Furthermore, a symmetric bidirectional conflict score, i.e., a key constraint difference index, is introduced. To evaluate in a symmetrical manner and The overall degree of conflict between them on key limiting information, when and When all key limiting information between the two parties is compatible and does not conflict, and All are 0, corresponding to It is also 0, when and When there is a significant conflict between one or more key limiting information of either party, the corresponding one-way conflict degree is... or The value will be higher, so the maximum of the two is taken to highlight it. and The overall conflict of key limiting information between them.
[0055] Furthermore, the key limiting information difference index is utilized. For the optimized Euclidean distance Further optimization yields the final effective distance between any two problem vectors. : Obtain a preset information conflict weight coefficient, calculate the product between the information conflict weight coefficient and the key limiting information difference index, and use the constant 1 and the sum of the product as the distance quadratic optimization coefficient between any two problem vectors; use the product between the distance quadratic optimization coefficient and the optimized Euclidean distance as the final effective distance between any two problem vectors.
[0056] The formula for calculating the final effective distance between any two problem vectors is as follows:
[0057]
[0058] in, This represents the final effective distance between any two problem vectors. This represents the optimal Euclidean distance between any two problem vectors, where 1 indicates a constant. This represents the preset information conflict weighting coefficient. This represents the key constraint information difference index between any two problem vectors.
[0059] It should be noted that, The value is 0.8, and this specific value can be optimized in a specific field based on experimental data to obtain the best results; no restrictions are imposed here. The key constraint information difference index is obtained by introducing symmetry analysis. This achieves a second round of refined and symmetrical constraint-aware correction for the effective distance, when When the value is close to 1, it indicates a serious conflict, and the optimized Euclidean distance needs to be further increased to enhance the semantic difference between the two; when When the value of is 0, it means that all the key constraints of the two problem vectors are compatible with each other and do not conflict. There is no need to make additional adjustments to the distance of the macro-topic that has been considered. In other words, the optimized Euclidean distance is used as the final effective distance.
[0060] The calculation of the final effective distance not only aligns the macro-topics but also maintains consistency in the specific constraints that determine the core semantics of the problem. This enables the HNSW algorithm to more effectively avoid candidates that may have similar macro-topics but conflict in specific problem scenarios and core constraints when selecting neighbors. Therefore, based on the above method for obtaining the final effective distance, the final effective distance between every two problem vectors in the problem vector library is obtained, and the optimized HNSW graph is constructed based on the final effective distance.
[0061] It should be noted that using the HNSW algorithm to construct the HNSW graph of the problem vector library is existing technology. However, in this embodiment of the invention, the optimization process of constructing the index graph of the problem vector library using the HNSW algorithm is based on the final effective distance. As a core metric, it is comprehensively applied to the entire index graph construction process of the HNSW algorithm. Specifically, when the HNSW algorithm performs its standard graph construction operations, in searching and selecting its nearest neighbor nodes at each level of the graph to establish connections for newly inserted nodes, and in maintaining the graph structure at each level to satisfy the small-world and navigability characteristics, all decisions involving distance comparisons between nodes, sorting, and distance-based neighbor selection no longer use the original Euclidean geometric distance. Instead, the calculations obtained using the embodiments of this invention are uniformly adopted. Therefore, the construction process of the HNSW graph will not be described in detail.
[0062] Thus, the optimized HNSW diagram was obtained.
[0063] Step S103: Perform an ANN search in the optimized HNSW graph to obtain problem recommendations that are highly relevant to the query semantic vector and feed them back to the user.
[0064] Since the final effective distance incorporates both macro-level thematic consistency and micro-level key information conflict, the edges (i.e., connections between nodes) of the HNSW graph constructed based on this optimized distance more realistically reflect the inherent logical connections and subtle semantic differences between questions within the professional domain. This significantly reduces misleading connections caused by simply relying on generalized semantic similarity, thereby optimizing the topology of the entire graph in terms of professional knowledge navigation. Therefore, after transforming the user's query into a query semantic vector, the optimized HNSW graph can be used to efficiently recall and recommend other highly relevant questions to assist users in knowledge exploration and deeper understanding. The general process of using the optimized HNSW graph to efficiently recall and recommend other highly relevant questions is as follows:
[0065] Optimize the HNSW diagram. Search: Using the query semantic vector as the query vector, an approximate nearest neighbor search (ANN search) operation is performed on the optimized HNSW graph. Since the construction process of the optimized HNSW graph has already adopted the final effective distance proposed in the embodiments of this invention... Therefore, its search process (including greedy walks within layers and jumps between layers) relies on distance judgments, taking into account the matching degree of domain expertise and key limiting information. Through ANN search, it efficiently retrieves semantic vectors matching the query from the optimized HNSW graph. The closest in the sense of distance Problem nodes (in this embodiment) (and their corresponding original question texts) form a high-quality set of candidate related questions.
[0066] Candidate Question Ranking and Final Recommendation: Recall of ANN Search A number of candidate relevant questions, based on their relationship with the query semantic vector. Sort the values in ascending order.
[0067] Results presentation: Selecting the top candidates from the sorted list of candidate questions indivual( As a preset recommended quantity, the embodiments of the present invention select The question is presented to the user as the final highly relevant question recommendation result.
[0068] It is worth noting that performing an ANN search on the constructed HNSW graph based on the user's query to return highly relevant questions to the user is an existing technology, which will not be elaborated on here.
[0069] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A highly relevant recommendation method for knowledge question answering based on large-model semantic enhancement, characterized in that, The method includes: Obtain the query question submitted by the user, and use a large language model to transform the query question into a query semantic vector; The process of constructing the index graph of the question vector library using the HNSW algorithm is optimized to obtain an optimized HNSW graph. The question vector library is constructed by converting all questions in the knowledge base into question vectors using a large language model. An ANN search is performed in the optimized HNSW graph to obtain questions that are highly relevant to the query semantic vector, which are then used to recommend and provide feedback to the user. The optimized method for obtaining the HNSW graph is as follows: For any two question vectors in the question vector library, obtain the Euclidean distance between the two question vectors, perform domain topic identification on the two question vectors to obtain the domain topic difference index between the two question vectors, and perform initial optimization on the Euclidean distance based on the domain topic difference index to obtain the optimized Euclidean distance; Extract the key constraint information of any two problem vectors to obtain the key constraint information difference index between any two problem vectors. Use the key constraint information difference index to optimize the optimized Euclidean distance again to obtain the final effective distance between any two problem vectors. Obtain the final effective distance between every two problem vectors in the problem vector library, and construct the optimized HNSW graph based on the final effective distance.
2. The knowledge question answering and highly relevant recommendation method based on large model semantic enhancement according to claim 1, characterized in that, The process of identifying domain topics for any two question vectors to obtain a domain topic difference index between any two question vectors includes: For any one of any two question vectors, the domain topic words or core phrases of the question text of the question vector are identified and extracted to obtain at least one domain topic word. Each domain topic word is converted into a corresponding semantic vector. All semantic vectors are averaged and pooled to obtain an aggregate vector. Obtain the aggregated vector of each of any two question vectors, and obtain the domain topic difference index between any two question vectors based on the cosine similarity of the aggregated vectors of each of any two question vectors.
3. The knowledge question answering and highly relevant recommendation method based on large model semantic enhancement according to claim 2, characterized in that, The step of obtaining a domain-topic difference index between any two question vectors based on the cosine similarity of the aggregated vectors of each question vector in any two question vectors includes: Obtain the cosine similarity between the aggregated vectors of each of any two question vectors, calculate the difference between the constant 1 and the cosine similarity, and record the difference of the preset ratio as the domain topic difference index between any two question vectors.
4. The knowledge question answering and highly relevant recommendation method based on large model semantic enhancement according to claim 1, characterized in that, The initial optimization of the Euclidean distance based on the domain-theme difference index to obtain the optimized Euclidean distance includes: Obtain a preset domain topic inconsistency weight coefficient, calculate the product of the domain topic inconsistency weight coefficient and the domain topic difference index, calculate the sum of the product and constant 1 as the initial distance optimization coefficient, and use the product between the Euclidean distance and the initial distance optimization coefficient as the optimized Euclidean distance.
5. The knowledge question answering and highly relevant recommendation method based on large model semantic enhancement according to claim 1, characterized in that, The step of extracting key constraint information from any two question vectors to obtain a key constraint information difference index between any two question vectors includes: For any one of any two question vectors, extract at least one key limiting information from the question text of the question vector. Use a large language model to obtain the semantic conflict score between each key limiting information and the question text of the other question vector. Take the maximum semantic conflict score as the overall semantic conflict score of the question vector. Obtain the overall semantic conflict score for each of any two question vectors, and based on the overall semantic conflict score for each of any two question vectors, obtain the key constraint information difference index between any two question vectors.
6. The knowledge question answering and highly relevant recommendation method based on large model semantic enhancement according to claim 5, characterized in that, The step of obtaining a key constraint information difference index between any two question vectors based on the overall semantic conflict score of each question vector in any two question vectors includes: The maximum value of the overall semantic conflict score for each of any two question vectors is taken as the key constraint information difference index between any two question vectors.
7. The knowledge question answering and highly relevant recommendation method based on large model semantic enhancement according to claim 1, characterized in that, The step of further optimizing the Euclidean distance using the key constraint information difference index to obtain the final effective distance between any two problem vectors includes: Obtain a preset information conflict weight coefficient, calculate the product between the information conflict weight coefficient and the key limiting information difference index, and use the constant 1 and the sum of the product as the distance quadratic optimization coefficient between any two problem vectors; use the product between the distance quadratic optimization coefficient and the optimized Euclidean distance as the final effective distance between any two problem vectors.
Citation Information
Patent Citations
Respiratory anesthesia knowledge retrieval type question answering method and system
CN119848199A
Power field knowledge question and answer optimization system based on large model retrieval enhancement generation and instruction supervision fine tuning
CN119961388A