A dialogue state awareness-based retrieval strategy dynamic switching method
Patent Information
- Application Number
- CN202611173554.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-04
- Publication Date
- 2026-10-09
AI Technical Summary
[0004]本发明解决的技术问题是:现有技术下智能客服难以从不同表达中精准识别用户意图,返回的检索结果不够精准,检索模式的落后难以适应动态交流,易产生上下文割裂;知识库过度依赖人工干预和维护,更新成本高、自我优化能力不足
基于动态调整的滑动窗口对用户对话选取和意图变体查询,灵活地适配于用户交流中对指代理解割裂和漂移意图识别的僵化,通过生成查询变体增强了检索的召回率,有效识别用户意图实现精准搜索。
Smart Images

Figure CN122885286A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of large language model retrieval enhancement generation and intelligent question answering knowledge retrieval technology, and in particular to a method for dynamically switching retrieval strategies based on dialogue state awareness. Background Technology
[0002] In recent years, intelligent customer service applications have become increasingly widespread. However, traditional retrieval-based customer service knowledge bases mainly rely on manual input of standard question-and-answer pairs and keyword or basic vector matching. The rules within the knowledge base are difficult to fully cover various questioning methods such as colloquialisms and abbreviations used by different users, resulting in insufficient retrieval and matching capabilities and low overall recall. Fixed-weight retrieval strategies are rigid and not adaptable to dynamic communication. In multi-turn dialogues, semantic drift and deviation from standard answers are prone to occur, resulting in low accuracy of responses.
[0003] In dialogue retrieval, traditional knowledge bases often rely on continuous manual intervention and maintenance to correct errors and update knowledge, which is costly and difficult to adapt to the long-term growth of business volume. On the other hand, the maintenance resources of static structures are large, and the continuous accumulation of invalid data during use also affects the retrieval accuracy, resulting in increased latency and wasted computing power. Summary of the Invention
[0004] The technical problem solved by this invention is that: under the existing technology, intelligent customer service has difficulty in accurately identifying user intent from different expressions, the returned search results are not accurate enough, the outdated search mode is difficult to adapt to dynamic communication, and it is easy to cause contextual fragmentation; the knowledge base relies too much on manual intervention and maintenance, the update cost is high and the self-optimization capability is insufficient.
[0005] To solve the above-mentioned technical problems, the present invention provides the following technical solution: A method for dynamically switching retrieval strategies based on dialogue state awareness includes the following steps: Step S1: Based on preset standard questions and answers as nodes, preset question categories, and semantic similarity, knowledge nodes are divided into different levels to construct a multi-layer semantic knowledge base.
[0006] Step S2: Extract the semantic matching preset standard questions of the user's current question, dynamically collect the degree of reference and topic shift in dialogue recognition based on the sliding window, and adjust the scope of the context window.
[0007] Step S3: Extract user semantics based on the content of the adjusted window, classify it into preset question categories, obtain standardized core intent, and generate multiple query variant statements as semantic center.
[0008] Step S4: Calculate the query granularity based on the query variant statements and the multi-layer semantic knowledge base, switch the retrieval state, and obtain multiple retrieval results.
[0009] Step S5: Merge the results from multiple retrieval paths to perform semantic deduplication, calculate the comprehensive confidence score, sort the results, and output the final result.
[0010] As a preferred embodiment of the dynamic switching method for retrieval strategies based on dialogue state awareness described in this invention, step S1 includes the following sub-steps: Step S101: Create leaf nodes based on preset standard questions and answers, and pre-classify based on preset question categories.
[0011] An initial knowledge base for question answering is obtained. Pre-defined standard questions and corresponding standard answers based on manual sorting are used as leaf detail nodes. The pre-defined standard questions are divided into pre-defined question categories based on core content to achieve pre-classification and obtain basic semantic scene tags.
[0012] Step S102: Based on the text of the standard question in the leaf nodes after pre-classification, perform vector encoding, use the hyperplane-based locality-sensitive hashing algorithm to bucket the vectors, and generate summary text for the set of leaf nodes falling into the same bucket based on the large language model to obtain summary nodes.
[0013] For all leaf node standard question texts, a unified embedding model is used to perform vector encoding and normalization to obtain standard question vectors. A set of random hyperplanes is fixed, and all vectors are projected onto the hyperplanes to generate binary hash codes. Vectors with the same hash codes are grouped into the same storage bucket. For all leaf node texts in each bucket, a unified summary text is generated based on a large language model to obtain the upper-level summary nodes.
[0014] Step S103: Recursively execute bucketing and summary generation until a preset depth is reached, then stop. Construct a multi-layer semantic knowledge base containing leaf layers and at least one summary layer. Calculate the mean vector of each layer as the semantic center vector of that layer and store it.
[0015] The process of vector encoding, hyperplane-based locality-sensitive hashing (LSH) bucketing, and large language model summarization is repeated for all the summary nodes generated in this round. This iterative recursion continues until a preset layer depth is reached, forming a complete multi-layer semantic knowledge base. At each layer, the mean vector of all node vectors in that layer is calculated and stored as the semantic center vector of that layer.
[0016] As a preferred embodiment of the dynamic switching method for retrieval strategies based on dialogue state awareness described in this invention, step S2 includes the following sub-steps: Step S201: Based on the large language model, the semantics of the current user's question are compressed. If the compressed semantics can directly match the standard question or the intent clarity is higher than the preset value, the answer is queried and returned.
[0017] Based on a large language model, the current user input question is semantically compressed, vector-encoded, and normalized. It is then quickly matched with the vector encoding of a standard question. If the compressed semantics can be directly matched, an answer is obtained. Alternatively, if the intent is clearer than a preset threshold, the answer with the highest similarity is directly output, skipping the window adjustment process.
[0018] Intent Clarity: This measures the degree to which the system independently understands the business intent based solely on the current user's input question, without relying on context.
[0019] Step S202: For intent clarity lower than the preset value, based on the multi-turn dialogue history, a sliding window of preset length is used to extract the most recent N rounds of dialogue messages, calculate the frequency of pronouns in the current user input as the pronoun density, and calculate the average semantic vector distance between the current user input and the most recent several rounds of dialogue messages as the intent drift value. For user inputs with ambiguous intent and clarity below a preset threshold, the most recent N rounds of dialogue messages are extracted based on a sliding window of a preset initial length. The frequency of pronouns and indicator words in the window is counted to obtain the referential density. The mean distance between the current user's question vector and the historical dialogue vectors in the window is calculated to obtain the intent drift value. Reference density: used to measure the degree to which the current user input depends on the preceding text, calculated as the ratio of pronouns to the total number of words in the dialogue.
[0020] Intent drift value: used to measure the degree of deviation between the current topic and previous conversations. It is calculated by averaging the distances of the current user's question vector to each historical conversation vector within the window.
[0021] Step S203: When the reference density is higher than the reference density threshold, the sliding window is expanded; when the intent drift value is higher than the intent drift threshold, the sliding window is shrunk; and the dialogue messages in the adjusted sliding window are used as valid context.
[0022] A tiered judgment is made by setting a reference density threshold and an intent drift threshold. If the reference density is higher than the density threshold, it means that there is a lot of contextual reference, and the sliding window needs to be expanded to obtain more historical dialogues. If the intent drift value is higher than the intent drift threshold, it means that the user's topic has been switched or shifted, and the window is shrunk to retain only a small number of recent dialogues. All dialogues in the adjusted window are used as valid context for subsequent intent extraction.
[0023] As a preferred embodiment of the dynamic switching method for retrieval strategies based on dialogue state awareness described in this invention, step S3 includes the following sub-steps: Step S301: Clean and refine user semantics based on the large language model, converge to the preset question category, and obtain standardized core intent.
[0024] Based on the large language model, all valid contexts within the sliding window are cleaned and compressed, and invalid content is filtered out. Based on the core semantics, user statements are converged to the preset question category described in step S1, and standardized core intent based on the preset question category and corresponding answer as constraints is obtained.
[0025] Step S302: Based on the standardized core intent as the semantic center, generate multiple query variants.
[0026] Based on standardized core intent as input context, a one-to-many batch delivery pattern is adopted to generate query variants of the core intent based on a large language model. During the generation process, the generated variants are used as context constraints for subsequent generation results to avoid variant duplication and semantic drift, while ensuring syntactic diversity.
[0027] As a preferred embodiment of the dynamic switching method for retrieval strategies based on dialogue state awareness described in this invention, step S4 includes the following sub-steps: Step S401: Calculate the knowledge level distance based on the query variant statement and the multi-layer semantic knowledge base, and calculate the normalized distance. Set a preset query threshold to determine the query status. The query status includes single-layer query and mixed query.
[0028] The cosine distance is calculated based on the query variant vector and the semantic center vectors of each layer stored in the multi-layer semantic knowledge base, and is used as the distance from the query variant vector to the knowledge layer of that layer.
[0029] The hierarchical normalized distance is calculated based on the two closest hierarchical levels. The query status is determined based on the hierarchical normalized distance, including single-level queries and mixed queries, and the retrieval level is determined.
[0030] Step S402: Based on the query status and retrieval level, perform targeted retrieval of query variants and obtain retrieval results for all query variants.
[0031] Based on their respective determined query states and retrieval levels, all query variants are directed to specific levels in the multi-layer semantic knowledge base for retrieval, and the node with the highest similarity is calculated and returned as the retrieval result for each query variant.
[0032] As a preferred embodiment of the dynamic switching method for retrieval strategies based on dialogue state awareness described in this invention, step S5 includes the following sub-steps: Step S501: Perform semantic deduplication processing based on the retrieval results of the query variant, and merge identical or similar candidate results to obtain a semantic unit set.
[0033] For semantic deduplication of all search results, the search results that are the same or have a similarity higher than a preset threshold are merged with the search results that have the highest similarity to the query variant, and are preferentially merged into items with higher similarity to obtain a set of semantic units.
[0034] Step S502: Calculate the overall confidence score of each search result, sort the semantic unit set in descending order based on the overall confidence score, and output the semantic unit with the highest ranking as the target search result.
[0035] The number of search hits is obtained based on the number of merged results. The overall confidence of each search result is calculated by combining the similarity with the corresponding query variant and the matching degree of the basic semantic scene tag. The overall confidence is sorted in descending order, and the result with the highest overall confidence is output as the answer to the user.
[0036] As a preferred embodiment of the dynamic switching method for retrieval strategy based on dialogue state awareness described in this invention, when multiple semantic cores are extracted from the sliding window, they are split and converged to a preset question category to obtain sub-intents, which are then used as multiple core retrievals and output based on semantic weight fusion.
[0037] If a user simultaneously submits intents under different basic semantic scenarios, these intents can be split and converged into preset question categories, allowing for independent retrieval of different sub-intents. Finally, the results obtained from each independent retrieval are concatenated and output to the user.
[0038] As a preferred embodiment of the dialogue-state-aware dynamic switching method for retrieval strategies described in this invention, the knowledge base employs a bidirectional optimization mechanism. After each retrieval, new associations are added for question variants with significant semantic differences based on the user's question. Leaf nodes are periodically pruned based on weight calculations, the number of result hits, time decay factors, and semantic matching degrees of associations, automatically optimizing the knowledge base. When new standard questions and answers are added, they are encoded and assigned to corresponding buckets, achieving local incremental updates to the knowledge base.
[0039] In knowledge base optimization, a two-way optimization mechanism is adopted. After each retrieval, if the semantics of the user's question differ significantly from the semantics of the stored corresponding answer, a leaf node for the corresponding answer can be added as a question variant. For long-term use, the knowledge base requires periodic optimization. Initially, all leaf nodes in the knowledge base have equal weights. Weights are increased based on the number of times a result is hit, with the weight of hits increased each time a retrieval result is returned to the user. Weights are decreased based on a time decay factor, with unused leaf nodes having their weights reduced over time. Combined with semantic matching, leaf nodes with weights below a preset weight are periodically pruned. For newly added standard questions and answers, they are encoded as leaf node vectors and assigned to corresponding buckets based on locality-sensitive hashing. Only the summary nodes of the affected buckets are locally updated, achieving local incremental updates to the knowledge base.
[0040] Result hit count: This indicates the number of times each association is used when returning search results to the user.
[0041] Time decay factor: used to indicate that the weight of unused leaf nodes decreases over time.
[0042] Relational semantic matching degree: used to represent the similarity between related statements stored in the knowledge base and standard questions.
[0043] As a preferred embodiment of the dynamic switching method for retrieval strategy based on dialogue state awareness described in this invention, a result pre-storage mechanism is adopted, which stores the query variants queried by the user and their corresponding retrieval results in a pre-storage cache pool. When user input is received, the results are matched based on semantic similarity from the pre-storage cache pool first.
[0044] To facilitate rapid retrieval, a pre-stored cache pool is established. Used query variations and corresponding search results are stored in the pre-stored cache pool. When a user enters a question, the results are matched based on semantic similarity from the pre-stored cache pool first.
[0045] As a preferred embodiment of the dynamic switching method for retrieval strategies based on dialogue state awareness described in this invention, the retrieval is optimized based on user feedback. When negative feedback is received on the retrieval results, the corresponding association weight is reduced. Correction instructions from human customer service are received, and the answers are updated or the association weights are adjusted based on the correction instructions. The adjusted leaf nodes are prioritized for subsequent retrievals.
[0046] User feedback can be used to optimize retrieval. When negative feedback is received from users, the relevance weight of the current result is reduced. When receiving correction instructions from customer service, the weight of the updated answer or related information in the knowledge base is adjusted during the basic updates and maintenance of the knowledge base, and the new leaf node is prioritized over the old leaf node for being hit.
[0047] The beneficial effects of this invention are: Based on a dynamically adjustable sliding window for selecting user dialogue and querying intent variations, it flexibly adapts to the rigidity of fragmented referential understanding and drifting intent recognition in user communication. By generating query variations, it enhances the recall rate of retrieval and effectively identifies user intent to achieve accurate search.
[0048] By establishing a hierarchical knowledge base based on hyperplane locality-sensitive hashing to store data, the complexity of management is reduced. It ensures that new knowledge can be inserted locally and only the affected buckets and upper-level summaries are updated, without the need to globally rebuild the entire graph. This significantly reduces the computing power and token overhead for knowledge base updates, and hierarchical retrieval also avoids the waste of computing power that requires traversing all nodes. Attached Figure Description
[0049] Figure 1The flowchart illustrates the steps of a method for dynamically switching retrieval strategies based on dialogue state awareness, as provided in one embodiment of the present invention.
[0050] Figure 2 The multi-layer semantic knowledge base model constructed for this invention. Detailed Implementation
[0051] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0052] according to Figure 1 The diagram shows a flowchart of a dynamic switching method for retrieval strategies based on dialogue state awareness provided by this invention. The flowchart includes the following specific steps: Step S1: Based on preset standard questions and answers as nodes, preset question categories, and semantic similarity, knowledge nodes are divided into different levels to construct a multi-layer semantic knowledge base; Step S2: Extract the semantic matching preset standard questions of the user's current question, dynamically collect the degree of reference and topic shift in dialogue recognition based on the sliding window, and adjust the scope of the context window; Step S3: Extract user semantics based on the content of the adjusted window, classify it into a preset question category, obtain standardized core intent, and use it as the semantic center to generate multiple query variant statements; Step S4: Calculate the query granularity based on the query variant statements and the multi-layer semantic knowledge base, switch the retrieval state, and obtain multiple retrieval results; Step S5: Merge the results from multiple retrieval paths to perform semantic deduplication, calculate the comprehensive confidence score, sort the results, and output the final result.
[0053] The steps for constructing a multi-layered knowledge base include: Step S101: Create leaf nodes based on preset standard questions and answers, and pre-classify based on preset question categories.
[0054] Based on the user's business, an initial knowledge base for question answering is obtained. Pre-defined standard questions and corresponding standard answers based on manual sorting are imported. These basic data serve as leaf detail nodes. Keywords are extracted based on core content to classify the pre-defined standard questions into pre-defined question categories. Keywords generated based on the pre-defined question categories are fixedly attached to the corresponding leaf nodes as the same basic semantic scene tags.
[0055] Step S102: Based on the text of the standard question in the leaf nodes after pre-classification, perform vector encoding, use the hyperplane-based locality-sensitive hashing algorithm to bucket the vectors, and generate summary text for the set of leaf nodes falling into the same bucket based on the large language model to obtain summary nodes.
[0056] For all leaf nodes, the standard question text is processed using a unified embedding model, BERT, to output the original d-dimensional semantic vectors. L2 normalization is then applied uniformly to eliminate differences in vector magnitude caused by varying text lengths. After normalization, the magnitude of all vectors is always equal to 1, at which point the dot product of two vectors is equivalent to cosine similarity.
[0057] A fixed set of pre-sampled d-dimensional random hyperplanes The normalized vector is then inverted with each hyperplane in turn, and the inner product is concatenated with the vectors to obtain a k-bit binary hash code, taking the value 0 or 1 depending on the sign of the inner product.
[0058] Normalized vectors with the same hash code are grouped into the same storage bucket, thus achieving automatic clustering of leaf nodes with similar semantics.
[0059] After bucketing is completed, a unified summary text is generated for all leaf node texts within a bucket based on a general large language model, which serves as the upper-level summary node.
[0060] Step S103: Recursively execute bucketing and summary generation until a preset depth is reached, then stop. Construct a multi-layer semantic knowledge base containing leaf layers and at least one summary layer. Calculate the mean vector of each layer as the semantic center vector of that layer and store it.
[0061] The process of vector encoding, hyperplane-based locality-sensitive hashing (LSH) bucketing, and large language model summarization is repeatedly performed on each round of summary nodes, continuously iterating and recursively building a multi-layer semantic knowledge base layer by layer until a preset layer depth is reached. For each layer, the mean vector of all node vectors in that layer is calculated and stored as the semantic center vector of that layer.
[0062] The initial matching and adjustment of the sliding window steps include: Step S201: Based on the large language model, the semantics of the current user's question are compressed. If the compressed semantics can directly match the standard question or the intent clarity is higher than the preset value, the answer is queried and returned.
[0063] The system performs semantic compression on the current user input question based on a large language model, implements vector encoding and normalization based on a BERT-like vector encoder, and quickly matches the vector encoding of the standard question. If the compressed semantics can be directly matched, the answer is obtained, or if the intent clarity is higher than a preset threshold, the answer with the highest similarity is directly output, skipping the window adjustment process.
[0064] The formula for intent clarity is: ; in, For the clarity of intent, For semantic clarity, For structural integrity, , These are the preset weighting coefficients for the two factors.
[0065] Semantic clarity: used to represent the degree of semantic alignment between user questions and standard questions in the knowledge base, calculated as the maximum cosine similarity between the current question vector and each standard question vector in the standard question library.
[0066] Structural completeness: This indicates whether a user's question contains a complete core semantic structure. It is based on a large language model to detect the structural completeness of the question. A question with a complete structure is 1.0, the presence of pronouns is 0.3, and the absence of keywords or other business-related substantive content is 0.
[0067] Preferred settings The weight is 0.7, giving higher weight to semantic clarity because semantic matching is the core basis for determining intent; The value is set to 0.3 because structural completeness is used as an auxiliary factor to correct ambiguous questions containing pronouns or omissions. It can be adjusted according to the actual situation, but the weight of semantic clarity must be higher than that of structural completeness.
[0068] For standard question vectors that are completely consistent with the semantic vector of the question, and standard question vectors that are most similar to the user's question with an intent clarity higher than a preset threshold, the answer can be returned directly without further steps.
[0069] Step S202: For intent clarity lower than a preset value, based on multi-turn dialogue history, a sliding window of preset length is used to extract the most recent N rounds of dialogue messages, calculate the frequency of pronouns in the current user input as the pronoun density, and calculate the average semantic vector distance between the current user input and the most recent several rounds of dialogue messages as the intent drift value.
[0070] For user inputs with ambiguous intent and clarity below a preset threshold, the most recent N rounds of dialogue messages are extracted using a sliding window of preset initial length. The frequency of pronouns and indicator words within the window is counted to obtain the referential density. The mean distance between the current user's question vector and the historical dialogue vectors within the window is calculated to obtain the intent drift value. The frequency of pronouns and demonstratives is statistically analyzed directly from words in the dialogue based on a local pronoun reference database and word segmentation.
[0071] Intent drift value: used to measure the degree of deviation between the current topic and previous conversations. It is calculated by averaging the distances of the current user's question vector to each historical conversation vector within the window.
[0072] This embodiment uses the cosine distance method to calculate the intended drift value.
[0073] Step S203: When the reference density is higher than the reference density threshold, the sliding window is expanded; when the intent drift value is higher than the intent drift threshold, the sliding window is shrunk; and the dialogue messages in the adjusted sliding window are used as valid context.
[0074] The preset referential density threshold and intentional drift threshold determine whether the sliding window needs adjustment.
[0075] Preferably, the reference density threshold range is 0.15-0.25. When it is below 0.15, the reference density is small and it is easy to identify the reference object. When it is above 0.25, the proportion of reference words in the dialogue is relatively high, which is easy to misidentify and requires the previous text to help understand. In this embodiment, the median is set to 0.2.
[0076] Preferably, the intentional drift threshold range is 0.5-0.75, and based on experimental measurements, this embodiment sets it to 0.60.
[0077] This experiment uses the publicly available multi-turn dialogue dataset MultiWOZ 2.2 as the basis for training and evaluation.
[0078] Vector Encoder: The all-MiniLM-L6-v2 pre-trained model is used to encode the dialogue text into 384-dimensional semantic vectors. The vectors are labeled based on the dialogue domain labels. When two consecutive rounds of user messages belong to the same domain, they are labeled as "topic continuation". When two consecutive rounds of user messages belong to different domains, they are labeled as "topic shift".
[0079] Semantic distance is calculated using cosine distance and normalized to [0,1]. The initial preset length of the sliding window is N=5, and a single-turn message refers to a single "user-system" alternation in the dialogue. Based on the Chinese pronoun table, the pronouns within the user messages in the window are statistically analyzed to obtain the pronoun density value, and the intent drift value is calculated based on the formula.
[0080] 1500 groups of topic continuation samples and 1500 groups of topic transition samples were extracted from the dataset. The accuracy A and the harmonic mean F1 score of accuracy and recall based on threshold classification were used as evaluation indicators.
[0081] Table 1 Sample Analysis
[0082] Table 2. Result Evaluation under Different Intended Drift Thresholds
[0083] Preferably, the intention drift threshold is set to 0.60.
[0084] Based on expanding or shrinking the sliding window with a step size of 1, the referential density and intent drift value are recalculated, and the sliding window is adjusted until it is within the threshold. When the referential density requires expanding the sliding window and the intent drift value requires shrinking the sliding window, the referential density judgment is given priority, and after performing the expansion operation, the sliding window will not be shrunk due to the determination of the intent drift value.
[0085] The intent-aware query variant generation step includes: Step S301: Clean and refine user semantics based on the large language model, converge to the preset question category, and obtain standardized core intent.
[0086] Based on all valid context within the sliding window, a large language model is used to clean and compress the data, filtering out invalid content such as interjections, and obtaining the core semantics to converge user speech to the preset question category described in step S1, thereby obtaining the standardized core intent based on the preset question category and corresponding answer as constraints.
[0087] When constructing prompts for a large language model, the corresponding answers to related questions under a preset question category are added as constraints when obtaining standardized core intents to enrich intent perception.
[0088] Step S302: Based on the standardized core intent as the semantic center, generate multiple query variants.
[0089] Based on standardized core intent as input context, a one-to-many batch delivery pattern is adopted to generate query variants of the core intent based on a large language model. During the generation process, the generated variants are used as context constraints for subsequent generation results to avoid variant duplication and semantic drift, while ensuring syntactic diversity.
[0090] Based on standardized core intent as input context, a one-to-many batch demonstration pattern is adopted. The core intent is macroscopically summarized and detailed based on a large language model, generating a fixed number of query variants with granularity extending along the knowledge hierarchy. During the generation process, the generated variants are used as context constraints for subsequent generation results to avoid variant duplication and semantic drift, while ensuring syntactic diversity.
[0091] The hierarchical retrieval step for determining the query status includes: Step S401: Calculate the knowledge level distance based on the query variant statement and the multi-layer semantic knowledge base, and calculate the normalized distance. Set a preset query threshold to determine the query status. The query status includes single-layer query and mixed query.
[0092] The cosine distance between the query variant vector and the semantic center vector stored at each level in the multi-layer semantic knowledge base is calculated and used as the distance from the query variant vector to the knowledge level of that level.
[0093] The hierarchical normalized distance is calculated based on the two closest levels. The ratio of the distance to the nearest level to the sum of the distances to the nearest and second-nearest levels is used as the hierarchical normalized distance. The query status, including single-level queries and mixed queries, is determined based on the hierarchical normalized distance, and the retrieval level is determined accordingly.
[0094] Preferably, the query threshold is set to 0.3-0.7. If it is below 0.3, it indicates that the current query variant vector is close to the nth level and there is no need to consider the retrieval of the mth level. If it is above 0.7, it indicates that the current query variant vector is close to the mth level and there is no need to consider the retrieval of the nth level. If it is between 0.3 and 0.7, it indicates that the current query variant vector has a tendency towards both levels and it is necessary to retrieve data from both levels.
[0095] Step S402: Based on the query status and retrieval level, perform targeted retrieval of query variants and obtain retrieval results for all query variants.
[0096] Based on their respective determined query states and retrieval levels, all query variants are directed to specific levels of the multi-layer semantic knowledge base for retrieval, and the node with the highest similarity is calculated and returned as the retrieval result for each query variant.
[0097] Preferably, cosine similarity is used, and the node with the highest similarity is returned.
[0098] The step of outputting the best matching result includes: Step S501: Perform semantic deduplication processing based on the retrieval results of the query variant, and merge identical or similar candidate results to obtain a semantic unit set.
[0099] For all search results, semantic deduplication is performed based on a large language model. Results that are identical or have a similarity higher than a preset threshold are merged with the search results that have the highest similarity to the query variant. Priority is given to merging them into items with higher similarity to obtain a set of semantic units.
[0100] Preferably, cosine similarity is used, and the similarity threshold is set to 0.85. The semantics of words with a similarity higher than 0.85 are basically the same and can be merged.
[0101] Step S502: Calculate the overall confidence score of each search result, sort the semantic unit set in descending order based on the overall confidence score, and output the semantic unit with the highest ranking as the target search result.
[0102] The number of search hits is obtained based on the number of merged results. The overall confidence of each search result is calculated by combining the similarity with the corresponding query variant and the matching degree of the basic semantic scene tag. The overall confidence is sorted in descending order, and the result with the highest overall confidence is output as the answer to the user.
[0103] The formula for calculating the overall confidence level S is: ; in, This refers to the basic semantic scene tag matching score, which is the percentage of hit tags out of the total number of basic semantic scene tags extracted from the user's semantics. The similarity between the search result and the corresponding query variant is used. To retrieve the number of hits.
[0104] Sort the overall confidence scores in descending order and output the result with the highest overall confidence score as the answer.
[0105] Preferably, a fixed number of results with high confidence levels can be output as related recommendations to the user.
[0106] After the search is completed, the weight of the output results is increased, and new answer-based associations are added.
[0107] It should be noted that 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 preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the protection scope of the present invention.
Claims
1. A method for dynamically switching retrieval strategies based on dialogue state awareness, characterized in that, Includes the following steps: Step S1: Based on preset standard questions and answers as nodes, preset question categories, and semantic similarity, knowledge nodes are divided into different levels to construct a multi-layer semantic knowledge base; Step S2: Extract the semantic matching preset standard questions of the user's current question, dynamically collect the degree of reference and topic shift in dialogue recognition based on the sliding window, and adjust the scope of the context window; Step S3: Extract user semantics based on the content of the adjusted window, classify it into a preset question category, obtain standardized core intent, and use it as the semantic center to generate multiple query variant statements; Step S4: Calculate the query granularity based on the query variant statements and the multi-layer semantic knowledge base, switch the retrieval state, and obtain multiple retrieval results; Step S5: Merge the results from multiple retrieval paths to perform semantic deduplication, calculate the comprehensive confidence score, sort the results, and output the final result.
2. The method for dynamically switching retrieval strategies based on dialogue state awareness as described in claim 1, characterized in that, Step S1 includes the following sub-steps: Step S101: Construct leaf nodes based on preset standard questions and answers, and pre-classify based on preset question categories; Step S102: Based on the text of the standard question in the leaf nodes after pre-classification, perform vector encoding, use the hyperplane-based locality-sensitive hashing algorithm to bin the vectors, and generate summary text for the set of leaf nodes falling into the same bin based on the large language model to obtain summary nodes. Step S103: Recursively execute bucketing and summary generation until a preset depth is reached, then stop. Construct a multi-layer semantic knowledge base containing leaf layers and at least one summary layer. Calculate the mean vector of each layer as the semantic center vector of that layer and store it.
3. The method for dynamically switching retrieval strategies based on dialogue state awareness as described in claim 2, characterized in that, Step S2 includes the following sub-steps: Step S201: Based on the large language model, the semantics of the current user's question are compressed. If the compressed semantics can directly match the standard question or the intent clarity is higher than the preset value, the answer is queried and returned. Step S202: For intent clarity lower than the preset value, based on the multi-turn dialogue history, a sliding window of preset length is used to extract the most recent N rounds of dialogue messages, calculate the frequency of pronouns in the current user input as the pronoun density, and calculate the average semantic vector distance between the current user input and the most recent several rounds of dialogue messages as the intent drift value. Step S203: When the referential density is higher than the first threshold, the sliding window is expanded; when the intent drift value is higher than the second threshold, the sliding window is shrunk; and the dialogue messages in the adjusted sliding window are used as valid context.
4. The method for dynamically switching retrieval strategies based on dialogue state awareness as described in claim 3, characterized in that, Step S3 includes the following sub-steps: Step S301: Clean and refine user semantics based on the large language model, converge to the preset question category, and obtain standardized core intent; Step S302: Based on the standardized core intent as the semantic center, generate multiple query variants.
5. The method for dynamically switching retrieval strategies based on dialogue state awareness as described in claim 4, characterized in that, Step S4 includes the following sub-steps: Step S401: Calculate the knowledge level distance based on the query variant statement and the multi-layer semantic knowledge base, and calculate the normalized distance. Set a preset query threshold to determine the query status. The query status includes single-layer query and mixed query. Step S402: Based on the query status and retrieval level, perform targeted retrieval of query variants and obtain retrieval results for all query variants.
6. The method for dynamically switching retrieval strategies based on dialogue state awareness as described in claim 5, characterized in that, Step S5 includes the following sub-steps: Step S501: Perform semantic deduplication processing based on the retrieval results of the query variant, and merge identical or similar candidate results to obtain a set of semantic units; Step S502: Calculate the overall confidence score of each search result, sort the semantic unit set in descending order based on the overall confidence score, and output the semantic unit with the highest ranking as the target search result.
7. The method for dynamically switching retrieval strategies based on dialogue state awareness as described in claim 6, characterized in that, When extracting multiple intents from a sliding window, the sub-intents are split and then converged to a preset question category, which is then used as multiple core retrievals and output based on weight fusion.
8. The method for dynamically switching retrieval strategies based on dialogue state awareness as described in claim 7, characterized in that, The knowledge base employs a two-way optimization mechanism. After each retrieval, leaf nodes are added to question variants with significant semantic differences based on user queries. The knowledge base is periodically pruned based on the number of result hits, time decay factor, and semantic matching degree through weight calculation. When new standard questions and answers are added, they are encoded and assigned to the corresponding buckets to achieve local incremental updates of the knowledge base.
9. The method for dynamically switching retrieval strategies based on dialogue state awareness as described in claim 8, characterized in that, A result pre-storage mechanism is adopted to store the query variations queried by the user and their corresponding search results in a pre-storage cache pool. When user input is received, the results are matched based on semantic similarity from the pre-storage cache pool first.
10. The method for dynamically switching retrieval strategies based on dialogue state awareness as described in claim 9, characterized in that, The system optimizes search based on user feedback. When negative feedback is received on the search results, the weight of the corresponding answer is reduced. When a correction instruction is received from a human customer service representative, the standard answer is updated or the associated weight is adjusted based on the correction instruction. The adjusted leaf node is prioritized in subsequent searches.