Intent recognition-based RAG enhancement methods, apparatus, devices, media, and products
By identifying user query intent and matching rewriting strategies, the problem that fixed query rewriting strategies in existing technologies cannot adapt to diverse user intents is solved, thereby improving the answer quality and stability of the question-and-answer system.
Patent Information
- Application Number
- CN202611630756.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-21
- Publication Date
- 2026-11-17
AI Technical Summary
Existing enterprise-level knowledge base question-answering systems employ fixed and singular query rewriting strategies, which fail to adapt to diverse user intents, resulting in inconsistent answer quality.
By performing semantic intent recognition on the original query input by the user, the target user's intent type is determined, and an appropriate query rewriting strategy is selected based on the intent type to generate a rewritten query. The query is then retrieved and relevance is judged, and the segment with the highest matching degree to the query requirement is selected to generate the answer.
It improves the accuracy and stability of the question-answering system's output quality, solves the problem of inconsistent answer quality caused by poor strategy adaptability, and enhances the targeting and adaptability of retrieval and recall.
Smart Images

Figure CN123115365A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of knowledge base question answering, and in particular to a method, apparatus, device, medium and product for RAG enhancement based on intent recognition. Background Technology
[0002] Current enterprise-level knowledge base question answering systems mainly use RAG (Retrieval-augmented Generation) as their main architecture. This system vectorizes the user's original query, retrieves relevant fragments from the knowledge base, and then feeds the fragments along with the original query into a large language model to generate the answer corresponding to the original query.
[0003] However, existing query rewriting strategies are fixed and singular (such as HyDE strategy, multi-query generation strategy, subquery decomposition strategy, etc.), which cannot adapt to diverse user intentions, resulting in inconsistent overall answer quality in question-answering systems. Summary of the Invention
[0004] The purpose of this application is to provide a method, apparatus, device, medium, and product for RAG enhancement based on intent recognition, which can improve the answer quality and stability of a question-and-answer system.
[0005] To achieve the above objectives, this application provides the following solution: In a first aspect, this application provides a RAG enhancement method based on intent recognition, including: The system receives the original query input by the user, performs semantic intent recognition on the original query, and determines the target user intent type corresponding to the original query; based on the target user intent type and the preset intent-policy mapping relationship, it determines the target query rewriting strategy corresponding to the target user intent type; based on the target query rewriting strategy, it rewrites the original query and determines at least one rewritten query; it performs retrieval based on at least one rewritten query and the original query to obtain multiple recall segments; based on the original query and multiple recall segments, it determines the relevance between the multiple recall segments and the original query; based on the relevance corresponding to the multiple recall segments, it determines the target segment from the multiple recall segments; and based on the original query and the target segment, it obtains the target answer.
[0006] Optionally, semantic intent recognition is performed on the original query to determine the target user intent type corresponding to the original query, including: Based on the original query and the preset first prompt word template, the first target prompt word is determined; the preset first prompt word template is used to instruct the large language model to determine the target user intent type corresponding to the original query according to the preset intent discrimination rules; the first target prompt word is input into the large language model to obtain the target user intent type.
[0007] Optionally, the intent discrimination rules include query type dimension, complexity dimension, domain feature dimension, and ambiguity dimension.
[0008] Optionally, based on the original query and multiple recall shards, the relevance between the multiple recall shards and the original query is determined, including: Based on the original query, multiple recall segments, and a preset second prompt word template, a second target prompt word is determined. The second target prompt word is used to instruct the large language model to determine the relevance of multiple recall segments according to the preset relevance judgment rules. The second target prompt word is input into the large language model to obtain the relevance of multiple recall segments.
[0009] Optionally, based on at least one rewritten query and the original query, a retrieval is performed to obtain multiple recall fragments, including: The search is performed based on at least one rewritten query and the original query to obtain multiple initial recall shards; based on the globally unique shard identifier corresponding to each initial recall shard, the multiple initial recall shards are deduplicated to obtain multiple recall shards.
[0010] Optionally, user intent types include fact-finding, analytical reasoning, comparative, vague verbal, and operational guidance.
[0011] Secondly, this application provides a RAG enhancement device based on intent recognition, comprising: The intent module is used to receive the original query input by the user, perform semantic intent recognition on the original query, and determine the target user intent type corresponding to the original query. The strategy module is used to determine the target query rewriting strategy corresponding to the target user intent type based on the target user intent type and the preset intent-strategy mapping relationship; The rewrite module is used to rewrite the original query based on the target query rewrite strategy, and to identify at least one query to be rewritten. The retrieval module is used to retrieve data based on at least one rewritten query and the original query, and obtain multiple recall fragments. The determination module is used to determine the relevance between multiple recall shards and the original query based on the original query and multiple recall shards; The filtering module is used to determine the target fragment from multiple recall fragments based on the correlation between the fragments. The question-and-answer module is used to obtain the target answer based on the original query and target shards.
[0012] Thirdly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the intent recognition-based RAG enhancement method described in the first aspect.
[0013] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the intent recognition-based RAG enhancement method of the first aspect described above.
[0014] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the intent recognition-based RAG enhancement method described in the first aspect.
[0015] According to the specific embodiments provided in this application, the following technical effects are disclosed: This application provides a RAG enhancement method based on intent recognition. By performing semantic intent recognition on the original query input by the user, the target user intent type is obtained, automatically distinguishing the user intent types corresponding to different queries and accurately capturing differences in user intent. By determining the target query rewriting strategy based on the target user intent type and a preset intent-strategy mapping relationship, corresponding rewriting methods can be adapted for queries with different intent types, fundamentally eliminating the problem of mismatch between rewriting strategies and user intent, and improving the targeting and adaptability of retrieval. The original query is rewritten based on the target query rewriting strategy, identifying at least one rewritten query, and then performing a retrieval based on the at least one rewritten query and the original query. The system retrieves multiple recall segments based on the original query. The relevance between these segments and the original query is determined. Based on this relevance, a target segment is selected. Using the original query as a unified benchmark, the relevance of the multiple segments retrieved through multi-path recall is assessed, and the target segment is selected based on this relevance. This process allows for the selection of content with the highest match to the query requirements from all segments, ensuring the contextual quality of the input large language model. Finally, by using the original query and target segment as a basis, the target answer is obtained. This effectively solves the problem of inconsistent answer quality caused by poor strategy adaptability, improving the overall accuracy and output quality stability of the question-answering system. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 An application environment diagram of the RAG enhancement method based on intent recognition provided in the embodiments of this application; Figure 2A flowchart illustrating the RAG enhancement method based on intent recognition provided in this application embodiment; Figure 3 A schematic diagram of the functional modules of the RAG enhancement device based on intent recognition provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0020] The RAG enhancement method based on intent recognition provided in this application can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be set up independently, integrated into server 104, or placed in the cloud or on another server. Terminal 102 can send a raw query to server 104, and server 104, upon receiving the raw query, processes it to obtain the target answer. Server 104 can then provide feedback to terminal 102 with the obtained target answer. Furthermore, in some embodiments, the RAG enhancement method based on intent recognition can also be implemented independently by server 104 or terminal 102. For example, terminal 102 can directly process the raw query, or server 104 can retrieve the raw query from the data storage system and process it.
[0021] The terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. The server 104 can be implemented using a standalone server or a server cluster composed of multiple servers, or it can be a cloud server.
[0022] In one exemplary embodiment, such as Figure 2As shown, a RAG enhancement method based on intent recognition is provided. This method is executed by a computer device, specifically by a terminal or server alone, or by both a terminal and a server. In this embodiment, the method is applied to... Figure 1 Taking server 104 as an example, the following steps are taken: S201 to S207.
[0023] S201. Receive the original query input by the user, perform semantic intent recognition on the original query, and determine the target user intent type corresponding to the original query.
[0024] For example, users can enter their questions through the human-computer interaction page provided on the front end, and this question is the original query.
[0025] Specifically, semantic intent recognition is performed on the original query to determine the target user intent type corresponding to the original query, including: Based on the original query and the preset first prompt word template, the first target prompt word is determined; the preset first prompt word template is used to instruct the large language model to determine the target user intent type corresponding to the original query according to the preset intent discrimination rules; the first target prompt word is input into the large language model to obtain the target user intent type.
[0026] For example, the preset first prompt word template can contain five parts, providing a unified judgment standard and output constraint for large language model classification; The first part includes role setting, clearly informing the large model that "you are a query intent classification expert, and you must strictly determine the intent type of user queries according to the given rules and examples"; the second part includes clear definitions of intent types and preset intent discrimination rules; the third part includes multiple (e.g., 2-3) typical query-intent type combinations for each of all intent types as annotation examples; the fourth part is the output format constraint, clearly requiring the large model to only output the corresponding intent type and not to output reasoning processes, explanations, or other redundant content; the fifth part is the original query.
[0027] For example, intent types may include fact-finding, analytical reasoning, comparative, vague verbal, and operational guidance. Among them, fact-based queries are queries targeting clear objective facts and definitive information; analytical reasoning queries include causal deduction, logical deduction, and multi-dimensional attribution requirements, requiring the combination of multiple pieces of information to reach a conclusion; comparative queries compare the differences, advantages, disadvantages, and applicable scenarios of two or more objects; vague colloquial queries are queries with colloquial expressions, ambiguous referents, and omitted information; and operational guidance queries are procedural queries targeting specific business processes, system operation steps, and procedural requirements.
[0028] For example, the preset intent discrimination rules may include query type dimension, complexity dimension, domain feature dimension, and ambiguity degree dimension; Among them, the query type dimension determines the type of inquiry by identifying interrogative words and sentence structure in the question; for example, if the question contains interrogative words such as "what / when / who" and points to a single objective information, it points to a fact query type; if the question contains interrogative words such as "why / how" and there is causal logic, it points to an analytical reasoning type; if the question contains expressions such as "difference / comparison" and there are multiple comparison objects, it points to a comparison type; if the question contains interrogative words such as "how / how to operate" and points to an action path, it points to an operation guidance type; if the question contains pronouns (such as this, that, that thing, etc.) or contains vague quantifiers or omitted information, it points to a vague colloquial type. The complexity dimension is the number of reasoning steps and entity associations required to answer the query; queries that can be answered by only a single entity and a single step of information matching are simple queries, corresponding to factual queries and fuzzy verbal queries; queries that involve multiple entities, multi-step causal chain derivation, and multi-dimensional information associations are complex queries, corresponding to analytical reasoning and comparative queries. The domain feature dimension identifies domain-specific terms in queries and combines them with domain attributes from the knowledge base to assist in determining intent. For example, queries containing financial terms such as "credit limit" and "margin ratio" can be further verified for factual or analytical attributes by combining term features; queries containing human resources and administration terms such as "approval process," "authority level," and "job establishment" can help determine operational guidance intent. The ambiguity level dimension is determined by using the perplexity of the large model or the pronoun density to judge whether the query is ambiguous. For example, "that rule" contains pronouns and vague quantifiers, which has a high degree of ambiguity and corresponds to the vague colloquial type. On the other hand, queries that are complete in expression, have clear direction, and have no vague referents have a low degree of ambiguity and correspond to the other four types of intents.
[0029] For example, typical query-intent type combinations may include: "Query: When was the company's employee attendance management policy promulgated?; Intent type: Real-time query", "Query: What is the cost difference between Project A management plan and Plan B?; Intent type: Comparison", "Query: How to take annual leave as mentioned last time?; Intent type: Vague and conversational", "Query: What is the process for employees to complete their resignation handover?; Intent type: Operational guidance".
[0030] For example, the original query can be filled into a preset first prompt word template to obtain the first target prompt word; the first target prompt word can be input into a large language model to obtain the target user intent type corresponding to the original query.
[0031] In this way, the target user intent type corresponding to the original query can be accurately determined by using a large language model through preset intent discrimination rules.
[0032] S202. Based on the target user intent type and the preset intent-policy mapping relationship, determine the target query rewriting strategy corresponding to the target user intent type.
[0033] For example, the corresponding target query rewriting strategy can be obtained by matching from the preset intent-policy mapping relationship based on the type of the target user intent.
[0034] For example, continuing with the above example of intent types, the preset intent-strategy mapping relationship may include "fact query intents corresponding to HyDE (hypothetical answer generation) strategy", "analysis and reasoning intents corresponding to subquery decomposition strategy", "comparison intents corresponding to multi-query generation strategy", "fuzzy verbal intents corresponding to query expansion strategy", and "operation guidance intents corresponding to Step-Back (background abstraction query) strategy".
[0035] It is understandable that the preset intent-policy mapping relationship can be dynamically adjusted according to changes in business scenarios and the characteristics of knowledge base content. It also supports extended configurations of adding new intent types and corresponding rewriting policies, without any restrictions.
[0036] S203. Based on the target query rewriting strategy, rewrite the original query and determine at least one rewritten query.
[0037] For example, a large language model can be invoked to semantically rewrite the original query based on the matched target strategy, generating at least one rewritten query.
[0038] For example, the HyDE strategy can generate hypothetical answer text as a rewritten query; the subquery decomposition strategy can break down a complex query into multiple subqueries (i.e., rewritten queries); the multi-query generation strategy can generate multiple rewritten queries with synonyms or different perspectives; the query expansion strategy can supplement the query with synonyms, keywords, and related concepts as rewritten queries; and the Step-Back strategy can generate higher-level, contextual rewritten queries.
[0039] It should be noted that rewriting the original query according to the query rewriting strategy to obtain the rewritten query is a common technique in this field and will not be elaborated here.
[0040] S204. Based on at least one rewritten query and the original query, perform a retrieval to obtain multiple recall fragments.
[0041] For example, the original query and all rewritten queries can be used as independent retrieval inputs, and multiple parallel vector semantic retrievals can be initiated to the vector knowledge base at the same time. Each retrieval uses cosine similarity to calculate the semantic similarity between the query vector and each knowledge segment vector in the knowledge base, and returns the top M (e.g., M=20) knowledge segments (i.e., recall segments) with the highest similarity ranking. Finally, multiple recall segments are obtained (it can be understood that the number of multiple recall segments obtained is the product of the sum of all queries and M).
[0042] It should be noted that obtaining recall fragments by retrieving based on the original query and the rewritten query is a conventional technique in this field and will not be elaborated upon here.
[0043] In some possible implementations, retrieval is performed based on at least one rewritten query and the original query to obtain multiple recall fragments, including: The search is performed based on at least one rewritten query and the original query to obtain multiple initial recall shards; based on the globally unique shard identifier corresponding to each initial recall shard, the multiple initial recall shards are deduplicated to obtain multiple recall shards.
[0044] It is understandable that multiple initial recall fragments are obtained through multi-path parallel retrieval, so the same knowledge fragment may be hit multiple times and appear repeatedly, which will lead to repeated calculations when determining relevance, thereby increasing the consumption of computing resources.
[0045] For example, during the knowledge base construction phase, each segment can be assigned a globally unique number (i.e., a globally unique segment identifier). Based on the globally unique segment identifier corresponding to the initial recalled segment, segments that appear multiple times in the initial recalled segments can be deduplicated, leaving only one, thereby preventing the same piece of knowledge from repeatedly entering subsequent processes.
[0046] For example, if the results returned by three-way retrieval include: original query hit: [shard A, shard B, shard C]; rewritten query 1 hit: [shard B, shard D, shard E]; rewritten query 2 hit: [shard A, shard D, shard F], these hit shards are the initial recall shards. After deduplication based on the globally unique identifier of the shards, the remaining shards include shard A, shard B, shard C, shard D, shard E, and shard F. These shards are the recall shards that enter the subsequent process.
[0047] This can reduce the consumption of computing resources and improve computing efficiency.
[0048] S205. Based on the original query and multiple recall shards, determine the correlation between the multiple recall shards and the original query.
[0049] For example, the semantic similarity between multiple recall segments and the original query can be calculated using cosine similarity, and the semantic similarity can be determined as the relevance between the multiple recall segments and the original query.
[0050] Some possible implementations involve determining the relevance of multiple recall shards to the original query based on the original query and multiple recall shards, including: Based on the original query, multiple recall segments, and a preset second prompt word template, a second target prompt word is determined. The second target prompt word is used to instruct the large language model to determine the relevance of multiple recall segments according to the preset relevance judgment rules. The second target prompt word is input into the large language model to obtain the relevance of multiple recall segments.
[0051] For example, the preset second prompt word template may include five parts, providing a unified judgment standard and output constraints for the large language model to determine relevance; The first part includes role setting, clearly informing the large model that "you are a search result ranking expert. Please determine the relevance of the query to each segment according to the relevance judgment rules, and rank all segments according to their relevance." The second part is the original query. The third part is a list of all recalled segments, with each entry in the list including a segment identifier and segment text. The fourth part is the output format constraints, requiring the large model to only output a list of segment identifiers arranged from high to low relevance, and not to output any other content. The fifth part is the relevance judgment rules.
[0052] For example, the relevance judgment rule may include prioritizing the matching of the core semantics of the query, with the fragments directly related to the core question ranked first; secondly, matching the supporting concepts and background information related to the topic corresponding to the query; and ranking the fragments that are irrelevant to the query semantics or deviate from the topic at the end.
[0053] For example, the original query can be filled into a preset second prompt word template to obtain the second target prompt word; the second prompt word can be input into a large language model to obtain a relevance ranking list of all segments.
[0054] S206. Based on the correlation between multiple recall fragments, determine the target fragment from the multiple recall fragments.
[0055] For example, multiple recall fragments can be sorted from largest to smallest based on relevance, and the top N (N is a positive integer with no limit on the value) recall fragments in the sort can be determined as target fragments.
[0056] S207. Based on the original query and target partitioning, the target answer is obtained.
[0057] For example, the target fragment can be used as contextual information and input into a large language model along with the original query to obtain the target answer.
[0058] For example, the prompt at this time may include four parts: first, the system role setting, such as "You are a professional knowledge base Q&A assistant, please answer the user's questions based on the provided references"; second, the references, that is, the main text content of the target segment; third, the user's original query; and fourth, the answer requirements, such as "Answer only based on the references, please clearly inform the user of any information not included in the references" and "Answer must cite the source of the references".
[0059] Understandably, after receiving the above prompts, the large model generates the final natural language answer based on the specified context segments and returns it to the user.
[0060] This application embodiment performs semantic intent recognition on the original query input by the user to obtain the target user intent type. It can automatically distinguish the user intent types corresponding to different queries and accurately capture the differences in user intent. By determining the target query rewriting strategy based on the target user intent type and the preset intent-strategy mapping relationship, it can adapt the rewriting method to queries with different intent types, eliminating the problem of mismatch between rewriting strategy and user intent from the root, and improving the targeting and adaptability of retrieval. By rewriting the original query based on the target query rewriting strategy, at least one rewritten query is determined. Retrieval is performed based on at least one rewritten query and the original query to obtain multiple recall scores. Based on the original query and multiple recall segments, the relevance between the recall segments and the original query is determined. Based on the relevance of these segments, the target segment is selected. Using the original query as a unified benchmark, the relevance of the multiple recall segments is assessed, and the target segment is selected based on this relevance. This allows for the selection of content with the highest match to the query requirements from all segments, thus ensuring the contextual quality of the input large language model. Finally, by using the original query and target segment as a basis, the target answer is obtained. This effectively solves the problem of inconsistent answer quality caused by poor strategy adaptability, improving the overall accuracy and output quality stability of the question-answering system.
[0061] Based on the same inventive concept, this application also provides an intent-based RAG enhancement apparatus for implementing the intent-based RAG enhancement method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations of one or more intent-based RAG enhancement apparatus embodiments provided below can be found in the limitations of the intent-based RAG enhancement method described above, and will not be repeated here.
[0062] In one exemplary embodiment, such as Figure 3 As shown, an intent-based RAG enhancement device is provided, comprising: The intent module 301 is used to receive the original query input by the user, perform semantic intent recognition on the original query, and determine the target user intent type corresponding to the original query. Strategy module 302 is used to determine the target query rewriting strategy corresponding to the target user intent type based on the target user intent type and the preset intent-strategy mapping relationship; The rewriting module 303 is used to rewrite the original query based on the target query rewriting strategy and identify at least one rewriting query. The retrieval module 304 is used to perform retrieval based on at least one rewritten query and the original query to obtain multiple recall fragments; The determination module 305 is used to determine the relevance between the multiple recall shards and the original query based on the original query and multiple recall shards; The filtering module 306 is used to determine the target fragment from multiple recall fragments based on the correlation between the multiple recall fragments. The question-answering module 307 is used to obtain the target answer based on the original query and the target shard.
[0063] The specific implementation methods and beneficial effects of this device embodiment can be found in the foregoing method embodiments, and will not be repeated here.
[0064] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 4 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements the aforementioned intent-based RAG enhancement method.
[0065] Those skilled in the art will understand that Figure 4The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0066] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0067] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0068] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0069] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0070] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0071] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0072] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0073] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A RAG enhancement method based on intent recognition, characterized in that, The intent-based RAG enhancement method includes: Receive the original query input by the user, perform semantic intent recognition on the original query, and determine the target user intent type corresponding to the original query; Based on the target user intent type and the preset intent-policy mapping relationship, determine the target query rewriting strategy corresponding to the target user intent type; Based on the target query rewriting strategy, the original query is rewritten to determine at least one rewritten query; Based on the at least one rewritten query and the original query, a retrieval is performed to obtain multiple recall fragments; Based on the original query and the multiple recall segments, determine the relevance between the multiple recall segments and the original query; Based on the correlation between the multiple recall segments, the target segment is determined from the multiple recall segments; Based on the original query and the target fragment, the target answer is obtained.
2. The RAG enhancement method based on intent recognition according to claim 1, characterized in that, The step of performing semantic intent recognition on the original query to determine the target user intent type corresponding to the original query includes: Based on the original query and the preset first prompt word template, a first target prompt word is determined; the preset first prompt word template is used to instruct the large language model to determine the target user intent type corresponding to the original query according to the preset intent discrimination rules; Input the first target prompt word into the large language model to obtain the target user intent type.
3. The RAG enhancement method based on intent recognition according to claim 1, characterized in that, The intent discrimination rules include query type dimension, complexity dimension, domain feature dimension, and ambiguity dimension.
4. The RAG enhancement method based on intent recognition according to claim 1, characterized in that, The step of determining the relevance between the multiple recall shards and the original query based on the original query and the multiple recall shards includes: Based on the original query, the multiple recall segments, and the preset second prompt word template, a second target prompt word is determined; the second target prompt word is used to instruct the large language model to determine the relevance of the multiple recall segments according to the preset relevance judgment rules. The second target prompt word is input into the large language model to obtain the relevance corresponding to the multiple recall segments.
5. The RAG enhancement method based on intent recognition according to claim 1, characterized in that, The process of retrieving data based on at least one rewritten query and the original query to obtain multiple recall fragments includes: Based on the at least one rewritten query and the original query, a retrieval is performed to obtain multiple initial recall fragments; Based on the globally unique fragment identifier corresponding to each initial recall fragment, the multiple initial recall fragments are deduplicated to obtain the multiple recall fragments.
6. The RAG enhancement method based on intent recognition according to claim 2, characterized in that, User intent types include fact-finding, analytical reasoning, comparative, vague verbal, and operational guidance.
7. A RAG enhancement device based on intent recognition, characterized in that, The intent-based RAG enhancement device includes: The intent module is used to receive the original query input by the user, perform semantic intent recognition on the original query, and determine the target user intent type corresponding to the original query. The strategy module is used to determine the target query rewriting strategy corresponding to the target user intent type based on the target user intent type and the preset intent-strategy mapping relationship; The rewriting module is used to rewrite the original query based on the target query rewriting strategy, and to determine at least one rewriting query; The retrieval module is used to perform retrieval based on the at least one rewritten query and the original query to obtain multiple recall fragments; The determination module is used to determine the relevance between the multiple recall segments and the original query based on the original query and the multiple recall segments; The filtering module is used to determine the target segment from the multiple recall segments based on the correlation between the multiple recall segments; The question-and-answer module is used to obtain the target answer based on the original query and the target segment.
8. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the RAG enhancement method based on intent recognition as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the RAG enhancement method based on intent recognition as described in any one of claims 1-6.
10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the RAG enhancement method based on intent recognition as described in any one of claims 1-6.
