Question and answer processing method and device
By matching multiple candidate dialogue rounds and grouping them into sessions within the dialogue system, and combining gain functions and contribution weight calculations, the contradiction between retrieval accuracy and contextual integrity is resolved, thereby improving the accuracy and coherence of generated responses.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHUHAI KINGSOFT OFFICE SOFTWARE
- Filing Date
- 2025-12-19
- Publication Date
- 2026-04-17
AI Technical Summary
Existing RAG-based dialogue systems cannot simultaneously ensure retrieval accuracy and contextual integrity in long-term memory scenarios, resulting in low accuracy of generated responses, poor contextual coherence, and high noise in retrieval results.
By matching multiple candidate dialogue rounds from the historical dialogue database, the primary relevance of each round to the current query is determined. These rounds are then grouped according to the dialogue, and the single-point strongest evidence value and multi-point cumulative evidence value are calculated using a gain function and contribution weight to generate the final response.
It significantly improves the accuracy, relevance, and logical consistency of generated responses, and optimizes the long-term memory utilization efficiency and user interaction experience of multi-turn dialogue systems.
Smart Images

Figure CN121882246A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more particularly to a question-and-answer processing method and apparatus. Background Technology
[0002] The performance of a dialogue system highly depends on its ability to utilize historical information, i.e., its "memory system." An ideal memory system should support long-term, multi-topic dialogues, ensuring the coherence and accuracy of the interaction. Currently, the main technical approach to achieving dialogue memory is Retrieval-Augmented Generation (RAG). This paradigm uses a complete dialogue history database as a knowledge source, retrieving relevant historical fragments as context to provide to a large language model. This method avoids information compression loss and has a simpler and more efficient architecture.
[0003] However, in the RAG framework, the performance of the retrieval module is crucial, and its core lies in the choice of retrieval granularity. Existing technologies mainly employ two strategies: round-level retrieval, which uses a single-turn dialogue as the unit. Its advantage is fine-grained granularity, enabling precise location of isolated evidence; its disadvantage is loss of context and fragmented results. Conversation-level retrieval, which uses the entire conversation as the unit. Its advantage is ensuring contextual integrity; its disadvantage is excessively coarse-grained granularity, introducing significant noise when only a small amount of information is relevant in a long conversation.
[0004] In summary, the current choice of retrieval granularity faces a dilemma: round-level retrieval sacrifices contextual integrity, while session-level retrieval sacrifices retrieval accuracy. This fundamental contradiction limits the performance of RAG-based dialogue systems in long-term memory scenarios, necessitating an innovative solution that balances retrieval accuracy and contextual integrity. Summary of the Invention
[0005] This application provides a question-answering processing method and apparatus to solve the technical problem that RAG-based dialogue systems cannot simultaneously ensure retrieval accuracy and contextual integrity due to their single retrieval granularity, resulting in low accuracy of generated responses, poor contextual coherence, and high noise in retrieval results.
[0006] Firstly, this application provides a question-and-answer processing method, the method comprising: In response to the current query, multiple candidate conversation rounds related to the current query are matched from the historical conversation database, and a first relevance of each candidate conversation round to the current query is determined; The multiple candidate dialogue rounds are grouped according to their respective sessions, and the following processing is performed on each group: based on the first relevance of each candidate dialogue round in the group, the second relevance of the candidate historical session corresponding to the group and the current query is determined; Based on the second relevance, a response to the current query is generated.
[0007] Secondly, this application provides a question-and-answer processing apparatus, the apparatus comprising: The dialogue matching module is used to respond to the current query by matching multiple candidate dialogue rounds related to the current query from the historical dialogue database, and determining a first relevance between each candidate dialogue round and the current query; The session matching module is used to group the multiple candidate dialogue rounds according to their respective sessions, and perform the following processing for each group: determine the second relevance between the candidate historical session corresponding to the group and the current query based on the first relevance of each candidate dialogue round in the group; The response module is used to generate a response to the current query based on the second relevance.
[0008] In one possible implementation, the session matching module includes: The first sorting unit is used to sort the candidate dialogue rounds in the group according to the first relevance from high to low, so as to obtain the relevance ranking of each candidate dialogue round in the group. The weight calculation unit is used to perform the following processing for each candidate dialogue round in the group: determine the contribution weight of the candidate dialogue round based on the first relevance and relevance ranking of the candidate dialogue round; The scoring calculation unit is used to determine the second relevance between the candidate historical session and the current query based on the contribution weight of each candidate dialogue round in the group.
[0009] In one possible implementation, the weight calculation unit is specifically used for: The first relevance of the candidate dialogue rounds is mapped to a gain value using a preset gain function; The relevance ranking of the candidate dialogue rounds and the gain value are set and calculated to obtain the contribution weight of the candidate dialogue rounds. Wherein, the gain value is positively correlated with the first correlation, the contribution weight is positively correlated with the gain value, and the contribution weight is negatively correlated with the correlation ranking.
[0010] In one possible implementation, the scoring calculation unit is specifically used for: The sum of the contribution weights of all candidate dialogue rounds in the group is determined as the second relevance between the candidate historical session and the current query.
[0011] In one possible implementation, the scoring calculation unit is specifically used for: Sort the candidate dialogue rounds in the group in descending order of contribution weight; The single strongest evidence value of the candidate historical session is determined based on the contribution weight of the top N candidate dialogue rounds. The multi-point cumulative evidence value of the candidate historical session is determined based on the contribution weight of all candidate dialogue rounds in the group. Based on the single strongest evidence value and the multi-point cumulative evidence value, the second relevance between the candidate historical session and the current query is obtained.
[0012] In one possible implementation, the scoring calculation unit obtains a second relevance between the candidate historical session and the current query based on the single strongest evidence value and the multi-point cumulative evidence value, including: Determine the adaptive weights corresponding to the candidate historical sessions; Based on the adaptive weights, the strongest single-point evidence value and the cumulative multi-point evidence value are weighted and fused to obtain the second relevance between the candidate historical session and the current query.
[0013] In one possible implementation, the scoring calculation unit determines the adaptive weights corresponding to candidate historical sessions, including: Based on the number of candidate dialogue rounds in the group and the number of all dialogue rounds in the candidate historical sessions corresponding to the group, the relevant information density of the candidate historical session corresponding to the current query is determined. The adaptive weight λ corresponding to the candidate historical session is determined based on the relevant information density. The adaptive weights are negatively correlated with the relevant information density.
[0014] In one possible implementation, the response module includes: A session recall unit is used to recall target session content from the historical session database based on the second correlation. The model response unit is used to input the target session content and the current query into the response model to generate a response to the current query.
[0015] In one possible implementation, the session recall unit includes: The second sorting subunit is used to sort the multiple candidate historical sessions according to their respective second relevance; The target session determination subunit is used to determine the target session from the multiple candidate historical sessions based on the sorting results; The information density calculation subunit is used to determine the relevant information density of the target session corresponding to the current query based on the number of candidate dialogue rounds in the target session and the total number of dialogue rounds in the target session. The recall subunit is used to recall target session content from the target session based on the relevant information density.
[0016] In one possible implementation, the recall subunit is specifically used for: If the density of the relevant information is greater than a first preset threshold, all dialogue rounds in the target session will be recalled as target session content. If the relevant information density is less than a second preset threshold, the first candidate dialogue turn in the target session is recalled as the target session content, or the first candidate dialogue turn and the context dialogue turn of the first candidate dialogue turn are recalled as the target session content; wherein, the first candidate dialogue turn corresponds to the first relevance, and the second preset threshold is less than the first preset threshold. If the relevant information density is not less than the second preset threshold and not greater than the first preset threshold, multiple second candidate dialogue rounds in the target session are recalled as target session content, or each second candidate dialogue round and its context dialogue round are recalled as target session content; wherein, the first relevance corresponding to the second candidate dialogue round satisfies the set condition.
[0017] In one possible implementation, the device further includes: The normalization module is used to normalize the second correlation based on the number of all dialogue rounds in the candidate historical sessions corresponding to the group after determining the second correlation between the candidate historical sessions corresponding to the group and the current query based on the first correlation of each candidate dialogue round in the group.
[0018] Thirdly, this application provides an electronic device, including: a processor and a memory, wherein the processor is configured to execute a question-and-answer processing program stored in the memory to implement the question-and-answer processing method described in any one of the first aspects.
[0019] Fourthly, this application provides a storage medium storing one or more programs that can be executed by one or more processors to implement the question-and-answer processing method described in any one aspect.
[0020] Compared with the prior art, the technical solution provided in this application has the following advantages: The method provided in this application, in response to the current query, firstly matches multiple candidate dialogue rounds related to the current query from the historical session database, and determines the first relevance of each candidate dialogue round to the current query. This achieves fine-grained matching by "dialogue round," filtering candidate dialogue rounds related to the current query from the historical session database, avoiding the noise redundancy of "overall recall due to partial information relevance" in session-level coarse retrieval, while ensuring that high-value key rounds are not missed. Subsequently, the multiple candidate dialogue rounds are grouped according to their respective sessions, and the following processing is performed on each group: based on each candidate dialogue round in the group... The first relevance determines the second relevance between the candidate historical sessions corresponding to the group and the current query. This not only restores the original conversation context of the candidate dialogue rounds and solves the problem of semantic fragmentation of isolated rounds, but also transforms the scattered single-round matching signals into a unified indicator that can be used for session screening through the aggregation of session-level scores, providing a basis for the accurate positioning of subsequent target sessions. Finally, the response to the current query is generated based on the effective quantification of the overall relevance between the session and the current query according to the second relevance. This directly improves the accuracy and contextual coherence of the historical information on which the response is based, thereby significantly enhancing the accuracy, relevance, and logical consistency of the final response, and optimizing the long-term memory utilization efficiency and user interaction experience of the multi-turn dialogue system. Attached Figure Description
[0021] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0022] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0024] Figure 1 A flowchart illustrating an embodiment of a question-and-answer processing method provided in this application; Figure 2 A flowchart illustrating another embodiment of the question-and-answer processing method provided in this application; Figure 3A flowchart illustrating another embodiment of the question-and-answer processing method provided in this application; Figure 4 A flowchart illustrating another embodiment of the question-and-answer processing method provided in this application; Figure 5 A block diagram illustrating an embodiment of a question-and-answer processing device provided in this application; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, 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, 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.
[0026] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0027] This application provides a question-answering processing method and apparatus that can effectively solve the problems of response deviation and logical incoherence caused by excessive historical information noise or semantic breaks in traditional multi-turn dialogues, ultimately improving the accuracy and coherence of the response to the current query and optimizing the user interaction experience.
[0028] Figure 1 This is a flowchart illustrating an embodiment of a question-and-answer processing method provided in this application. Figure 1 As shown, the method includes the following steps: Step 101: In response to the current query, match multiple candidate conversation rounds related to the current query from the historical conversation database, and determine the first relevance of each candidate conversation round to the current query.
[0029] In this context, the current query refers to the input content initiated by the user to the dialogue system (such as intelligent customer service, intelligent assistant, chatbot, etc.) in a multi-turn dialogue interaction scenario, which requires the system to generate a response (including a response or information support). It is the direct expression of the user's needs.
[0030] In a multi-turn dialogue system targeting "long-term memory," the current query may be linked to historical interaction information to obtain a coherent and personalized response (e.g., after asking "How to upgrade membership," a follow-up question could be followed by "What exclusive customer service services can I enjoy after upgrading?"). Alternatively, it may be a completely new input request independent of past conversations (e.g., "Introduce the basic membership benefits of your platform"). It should be noted that regardless of whether the current query is linked to historical interaction information, the technical framework provided in this application's embodiments can be adapted to achieve accurate responses.
[0031] A turn refers to a single-round question-and-answer interaction unit between a user and the system (or intelligent assistant) during a session, which is a pair of messages consisting of "user question / instruction + system response". A session, on the other hand, is a continuous sequence of interactions between a user and the system over a period of time. A session usually contains multiple turns (such as a complete interaction between a user and the system around "product consultation - order placement - logistics inquiry" which constitutes a session).
[0032] In the technical solution provided in this application embodiment, in response to the current query, a "fine-grained matching" strategy is first adopted, with a single dialogue round as the basic matching unit, rather than the entire session. This can effectively avoid the problem of "noise redundancy caused by overall recall due to the correlation of some information within the session" in session-level coarse-grained matching, and accurately locate relevant information scattered in different sessions.
[0033] As an optional implementation, step 101 employs a "preliminary screening + fine sorting" process to ensure the recall and precision of the search results. Specifically, in the preliminary screening stage, traditional retrieval algorithms (such as BM25) are integrated with dense vector similarity search technology. The former, based on statistical features such as word frequency and inverse document frequency, quickly filters out obviously irrelevant rounds that do not contain the core keywords of the query (e.g., excluding rounds without keywords such as "refund" or "refund fee" when the query is "refund"), and has the advantage of high computational efficiency. Dense vector similarity search technology transforms the current query and each dialogue round into high-dimensional, continuous numerical vectors (i.e., dense vectors) through a pre-trained language model. These vectors can encode the deep semantic information of the text, and then, based on the spatial distance between the vectors, the search results are analyzed. Dissimilarity (such as cosine similarity) captures deep semantic relationships in text, making up for the shortcomings of traditional algorithms in implicit semantic matching. The combination of the two achieves coverage of all potentially relevant dialogue rounds. In the fine ranking stage, a fine ranking model (such as Cross-encoder) performs deep semantic matching calculations on the candidate dialogue rounds obtained from the initial screening. This model directly models the semantic relationship strength between the two by simultaneously inputting the "current query + candidate dialogue round" pair, and outputs accurate first relevance (i.e., a quantitative indicator reflecting the semantic matching degree between the candidate dialogue round and the current query, which can be expressed as a specific value or percentage).
[0034] Accordingly, in one embodiment, determining the first relevance between a candidate dialogue turn and the current query includes generating a first semantic vector (which can be represented by a dense vector) for the candidate dialogue turn, generating a second semantic vector (which can also be represented by a dense vector) for the current query, and determining the first relevance based on the similarity between the first semantic vector and the second semantic vector. The similarity can be calculated using cosine similarity or vector dot product.
[0035] The above embodiments primarily determine the primary relevance based on the semantic similarity of text. However, in practical applications, other methods can also be used to determine the primary relevance between candidate dialogue rounds and the current query. For example, the dimension of "degree of association" can be introduced. The degree of association focuses on identifying whether there is a direct or indirect logical connection between key factual information such as specific entities, events, times, and numbers mentioned in the text, even if they differ in literal expression or have a large semantic vector distance. For example, the current query is "meeting minutes at 10:00 on December 19th," while the content of a candidate dialogue round is "the next steps have been determined at this morning's meeting." If similarity is calculated solely based on semantic vectors, the semantic similarity score may be low due to the difference in expression between "10:00 on December 19th" and "this morning." However, if time analysis can be performed by combining the context (such as the timestamp of the dialogue), and it can be identified that "this morning" in this historical conversation actually refers to "the morning of December 19th," and thus it can be determined that both refer to the same specific event, then although the semantic similarity is not high, the degree of factual association is very high. In practical applications, the degree of such association can be evaluated by combining rule matching, entity recognition, time normalization, or specialized fact association models, and finally integrated into the comprehensive calculation of the first relevance, so as to more comprehensively and accurately reflect the true relevance between the candidate dialogue rounds and the current query.
[0036] Through the above process, step 101 provides a high-quality, low-noise set of candidate dialogue rounds for the subsequent conversation aggregation and rearrangement stage, thus laying the foundation for ensuring the accuracy of the final recall results.
[0037] Furthermore, in practical applications, the basic unit of the aforementioned turn-level retrieval—the dialogue turn—can be defined as a turn chunk, which is a dialogue segment composed of several consecutive dialogue turns and possessing relatively complete semantics. Specifically, the turn chunk, as the basic unit of indexing and retrieval, can be constructed in ways including but not limited to: 1. A fixed-size turn window, such as dividing two to three consecutive dialogue turns into one chunk. 2. Dynamic division based on semantic boundaries, such as segmenting turn chunks according to the natural shift in dialogue topics. Using the turn chunk as the basic unit has the advantage of achieving a better balance between the accuracy of turn-level retrieval and the contextual completeness of conversation-level retrieval. It avoids the contextual insufficiency that may exist with a single turn and prevents information redundancy that may arise from a complete conversation. This definition expands the application flexibility of the technical solution in this application, enabling it to adapt to the different contextual granularity requirements in different scenarios.
[0038] Step 102: Group the multiple candidate dialogue rounds according to their respective sessions, and perform the following processing for each group: Determine the second relevance between the candidate historical sessions corresponding to the group and the current query based on the first relevance of each candidate dialogue round in the group.
[0039] In the technical solution provided in this application, to avoid context fragmentation caused by single-round retrieval, the scattered candidate dialogue rounds are reorganized according to their original "sessions" to form several groups. Each group corresponds to a complete historical session, and the group contains all candidate dialogue rounds matched in step 101 in its corresponding historical session. This achieves the return of candidate dialogue rounds to their original session framework, making up for the context loss defect of round-level retrieval.
[0040] For example, the historical session database S={S1,S2,…,S…} n}, where each session S j ={t j1 ,t j2 ,…, t jm}, containing a series of dialogue rounds t ji Each dialogue round t ji Associated metadata, including but not limited to session ID (such as S j The total number of conversation rounds, etc., can be used as a basis for the "conversation ID" associated with the candidate conversation rounds output in step 101. The scattered candidate conversation rounds can be reorganized according to the rule of "grouping the same conversation ID into a group" to form several groups, and each group corresponds to a complete historical conversation.
[0041] Subsequently, the historical sessions obtained through the above grouping and integration are used as candidate historical sessions, and a comprehensive second relevance is calculated for each candidate historical session. This second relevance is a quantitative indicator reflecting the semantic matching strength between the candidate historical session and the current query (the specific form can be a specific numerical value or percentage). Here, the "candidate historical session" serves to provide a standardized processing object with complete context and directly comparable scores for subsequent processes. It transforms the fine-grained round-level matching signal (i.e., the first relevance) in step 101 into a unified evaluation indicator at the session level, ultimately achieving the core goal of hybrid granularity retrieval that "balances the accuracy of round-level retrieval with the completeness of session context." This design effectively overcomes the inherent granularity contradiction in existing technologies, where "round-level retrieval is prone to losing contextual logic, and session-level retrieval is difficult to accurately quantify matching degree," thereby providing a reliable evaluation basis with contextual relevance for the subsequent ranking and accurate recall of candidate historical sessions.
[0042] In one embodiment, when determining the second relevance between candidate historical sessions and the current query, instead of simply accumulating the first relevance of the candidate conversation rounds contained within them, a dynamic fusion strategy is employed to achieve a more intelligent and robust session-level importance assessment. The specific method for determining the second relevance between candidate historical sessions and the current query will be explained below. Figure 2 The illustrated embodiments are explained in detail here, but will not be described in detail here.
[0043] Step 103: Generate a response to the current query based on the second relevance.
[0044] In one embodiment, the response generation process in step 103 is implemented through a two-stage process that includes content retrieval and model generation. This process first transforms the abstract second relevance into specific contextual material, thereby driving the response model to generate the final output. Specifically, generating a response to the current query based on the second relevance includes: retrieving target session content from the historical session database based on the second relevance; and inputting the target session content and the current query into the response model to generate a response to the current query.
[0045] The step of retrieving target session content from the historical session database based on the second relevance is a target session content retrieval step based on the second relevance. The main task is to accurately extract the target session content with the highest matching degree to the current query and the greatest support value for downstream response from the historical session database based on the correspondence between the candidate historical sessions output in step 102 and the second relevance, through the set filtering logic, so as to provide high-quality historical context support for the subsequent response model.
[0046] As for the specifics of how the target session content is retrieved from the historical session database based on the second relevance, this will be explained below. Figure 4The illustrated embodiments are explained in detail here, but will not be described in detail here.
[0047] Subsequently, the target session content retrieved through the aforementioned intelligent retrieval, rearrangement, and optimization is used as enhanced contextual information and input into the response model along with the current query. Because the provided contextual information (target session content) is relevant, complete, and concise, the response model can more accurately understand the query intent and historical context, thereby outputting a coherent, accurate, and personalized final response.
[0048] The technical solution provided in this application, in response to the current query, firstly matches multiple candidate dialogue rounds related to the current query from the historical session database, and determines the first relevance of each candidate dialogue round to the current query. This achieves fine-grained matching by "dialogue round," filtering candidate dialogue rounds related to the current query from the historical session database, avoiding the noise redundancy of "overall recall due to partial information relevance" in session-level coarse retrieval, while ensuring that high-value key rounds are not missed. Subsequently, the multiple candidate dialogue rounds are grouped according to their respective sessions, and the following processing is performed on each group: based on the first relevance of each candidate dialogue round in the group, the group corresponding to the... The second relevance between candidate historical sessions and the current query not only restores the original session context of candidate dialogue turns, solving the problem of semantic fragmentation in isolated turns, but also transforms scattered single-turn matching signals into unified indicators that can be used for session filtering through the aggregation of session-level scores, providing a basis for the accurate positioning of subsequent target sessions. Finally, the effective quantification of the overall relevance between the session and the current query based on the second relevance generates a response to the current query, directly improving the accuracy and contextual coherence of the historical information used to generate the response, thereby significantly enhancing the accuracy, relevance, and logical consistency of the final response, and optimizing the long-term memory utilization efficiency and user interaction experience of the multi-turn dialogue system.
[0049] Figure 2 A flowchart illustrating another example of a question-and-answer processing method provided in this application. Figure 2 The process shown is in Figure 1 Based on the illustrated process, an exemplary implementation is described to determine the second relevance between the candidate historical sessions corresponding to a group and the current query, based on the first relevance of each candidate dialogue round in the group. For example... Figure 2 As shown, it includes the following steps: Step 201: Sort the candidate dialogue rounds in the group according to their first relevance from high to low to obtain the relevance ranking of each candidate dialogue round.
[0050] In step 201, all candidate dialogue rounds belonging to the same group selected in step 101 are sorted in descending order of "highest relevance to lowest". After sorting, each round is assigned a "relevance ranking". It can be understood that the ranking value is negatively correlated with the importance of the dialogue round. The smaller the ranking value (e.g., 1), the higher the matching degree between the dialogue round and the current query within its respective session, and the higher the priority of its information value; conversely, the larger the ranking value (e.g., 10, 20), the lower the matching degree between the dialogue round and the current query within its respective session, and the lower the priority of its information value.
[0051] One more point to clarify: the “relevance ranking” here only represents the relative importance of dialogue turns within the same session, not the global ranking result. The negative correlation between the ranking value and the importance of turns only applies within the group, ensuring that when calculating the overall score of the session, the focus is on the value comparison of turns within the group.
[0052] For example, suppose step 101 outputs 5 candidate dialogue rounds, and after step 102, they are grouped according to their respective conversations, resulting in two groups: Group A of sessions: including rounds t1 (first correlation 0.94), t2 (first correlation 0.89), and t3 (first correlation 0.82); Session B group: includes rounds t4 (first correlation 0.71) and t5 (first correlation 0.65).
[0053] Then, internal sorting is performed on each of the two groups: Sorting within the conversation group A: sorted in descending order of score as t1→t2→t3, with corresponding intra-group relevance rankings of t1(1), t2(2), and t3(3). The ranking of t3 as 3 only indicates that it ranks third in matching degree within the conversation group A, and its information value is lower than t1 and t2 in the same group. It has no direct ranking correlation with the round of the conversation group B. Sorting within the Session B group: sorted in descending order of score as t4→t5, with corresponding intra-group relevance rankings of t4(1) and t5(2). Here, t4's ranking of 1 indicates that it has the highest matching degree in the Session B group, and even though its global score (0.71) is lower than t3 (0.82) in the Session A group, it does not affect its priority within this group.
[0054] This sorting logic within groups not only aligns with the core requirement of "conversation-level aggregation" (avoiding priority confusion across conversation rounds), but also provides a precise relative position basis for subsequent steps to calculate the contribution weight of rounds within the group, ensuring that the overall score of each conversation is driven only by its high-value rounds.
[0055] Step 202: Perform the following processing for each candidate dialogue round in the group: Determine the contribution weight of the candidate dialogue round based on the first relevance and relevance ranking of the candidate dialogue round.
[0056] Among them, the contribution weight of the candidate dialogue round is a quantitative value that measures the role of a single candidate dialogue round in the "semantic matching between the session to which it belongs and the current query". The higher the contribution weight, the greater the value of the information contained in the dialogue round in interpreting the current query and supporting the overall matching degree of the session. Conversely, the lower the contribution weight, the less value of the information contained in the dialogue round in interpreting the current query and supporting the overall matching degree of the session.
[0057] As described in step 202, the contribution weight is an indicator that accurately reflects the contribution of a candidate dialogue turn to the overall matching degree of the session by combining the first relevance of the candidate dialogue turn with the relevance ranking determined in step 201. Specifically, the combination of "first relevance" and "relevance ranking" is not a simple summation, but rather carries the dual-dimensional value of "precise matching degree" and "global priority" respectively. The first relevance originates from the calculation of fine-grained ranking models such as Cross-encoder in step 101 and is a direct reflection of the semantic association strength between the current query and the candidate dialogue turn. For example, when a user queries "member refund process", the first relevance of the dialogue turn that mentions "refund applications must be submitted through the APP's 'My Orders - After-sales' entry, and the review period is 1-3 working days" will be significantly higher than that of the dialogue turn that only mentions "refund applications must be submitted through the APP's 'My Orders - After-sales' entry, and the review period is 1-3 working days". The dialogue turn that generally states "Refunds can be processed by contacting customer service" directly reflects the "direct relevance" of the turn information to the query needs. The relevance ranking, on the other hand, comes from the descending order of step 201 and is a measure of the "relative importance" of the dialogue turn within the conversation. The higher the ranking (e.g., 1st or 2nd), the closer the dialogue turn is to the core needs of the current query within the conversation, and the more likely it is to be key information supporting the conversation's matching degree. The lower the ranking (e.g., 10th or 15th), the more it leans towards auxiliary or indirectly related content, and its contribution to the overall matching degree of the conversation is relatively limited.
[0058] This "dual-dimensional fusion" design effectively avoids the shortcomings of relying solely on a single indicator: if weights are calculated based solely on the first relevance, the priority differences of dialogue turns within the same conversation group may be overlooked. For example, if there are two dialogue turns with similar scores in the same group, turn A with a score of 0.86 (ranked 3rd in the group) and turn B with a score of 0.85 (ranked 4th in the group), with a difference of only 0.01, it would be easy to assume that turn A and turn B contribute similarly to the conversation based solely on the scores. However, from the perspective of the group ranking, turn A, due to its higher ranking, means that it is closer to the core needs of the current query among the relevant turns in the conversation, and its actual contribution to the overall matching degree of the conversation should be higher than that of turn B. Thus, relying solely on scores will mask the value differences brought about by this intra-group priority. On the other hand, if only relevance ranking is used, it is impossible to distinguish turns with adjacent rankings but significant score differences (for example, turn ranked 2nd with a score of 0.93 and turn ranked 3rd with a score of 0.72. Although they are ranked similarly, the difference in information value and matching strength is obvious, and the contribution weight should reflect this difference).
[0059] By unifying and quantifying "precise match degree (i.e., first relevance)" and "global priority (i.e. relevance ranking)" into contribution weights, a refined single-round value basis is provided for subsequent session aggregation and re-ranking. This ensures that when calculating the overall match degree of the session, the core contribution of high-value rounds can be highlighted, while the round value will not be misjudged due to the limitations of a single indicator. This guarantees the accuracy of session aggregation scoring from the source and lays the foundation for the final selection of high-matching sessions.
[0060] In one embodiment, determining the contribution weight of a candidate dialogue round based on the first relevance and relevance ranking of the candidate dialogue rounds includes: mapping the first relevance of the candidate dialogue rounds to a gain value using a preset gain function; performing a setting operation on the relevance ranking and gain value of the candidate dialogue rounds to obtain the contribution weight of the candidate dialogue rounds; wherein the gain value is positively correlated with the first relevance, the contribution weight is positively correlated with the gain value, and the contribution weight is negatively correlated with the relevance ranking.
[0061] The gain value is a quantitative measure of information value and is positively correlated with the primary relevance: the higher the primary relevance, the closer the semantic match between the dialogue turn and the current query, and the higher the gain value after mapping by the gain function, representing higher information value. Conversely, dialogue turns with lower primary relevance have correspondingly lower gain values, representing lower information value. Therefore, the core purpose of introducing the gain function is to amplify the value difference between high-rated and low-rated dialogue turns through a unified value transformation rule, avoiding the problem of "insufficient identification of high-value turns" caused by a flat distribution of original ratings.
[0062] In one embodiment, the first relevance of candidate dialogue turns is mapped to a gain value using the gain function exemplified by formula (a) or formula (b): Formula (1) Formula (II) in, Indicates the gain value. This indicates the first correlation, where a and b are constants, usually empirical values.
[0063] As can be seen, the gain functions exemplified by formulas (i) and (ii) above are monotonically increasing functions, thus satisfying the setting that the gain value is positively correlated with the first correlation. It should be noted that formulas (i) and (ii) are merely exemplary implementations of the gain function, and the embodiments of this application do not limit them.
[0064] Subsequently, the relevance ranking and gain value are used to perform a setting operation to obtain the contribution weight. In one embodiment, the aforementioned "setting operation" follows the core logic of "contribution weight = gain value / loss factor," where the value of the "loss factor" is directly determined by the relevance ranking of that round. The higher the ranking (e.g., ranking 1st or 2nd in the same session group), the smaller the loss factor; the lower the ranking (e.g., ranking 8th or 9th in the same session group), the larger the loss factor. This design essentially differentiates the gain value through the sorting order: rounds with higher rankings do not require excessive loss, and their original gain value (corresponding to high primary relevance and strong semantic matching) can be more fully converted into contribution weight; rounds with lower rankings need to reduce the proportion of gain value through a larger loss factor, thereby highlighting the value difference brought about by the sorting, and ultimately accurately implementing the core design goal of "contribution weight is positively correlated with gain value and negatively correlated with relevance ranking."
[0065] Under this logic, the calculation of contribution weight can naturally adapt to two core scenarios, ensuring the rationality of round value assessment: On the one hand, when the relevance rankings of two rounds are close (such as the 3rd and 4th rounds within the same session group), the round with a higher gain value (corresponding to the round with better primary relevance and closer alignment with query requirements) will receive a higher contribution weight due to its larger numerator, fully reflecting the principle of "matching strength priority". Even if the rankings are similar, the round with stronger matching degree can still highlight its core value. On the other hand, when the gain values of two rounds are similar, the round with a higher ranking will have a smaller loss factor, resulting in a higher contribution weight. This result reflects the principle of "priority within the group". Even if the matching strengths are similar, the higher-ranked round that is closer to the core query requirements can still occupy a higher weight in the overall score of its session.
[0066] In one embodiment, the above setting operation is implemented using the following formula (iii): Formula (3) Where k represents the relevance ranking.
[0067] For example, suppose candidate dialogue round t1 (first relevance 0.94, ranking 1) and candidate dialogue round t2 (first relevance 0.89, ranking 2). If the gain function shown in Formula (I) above is used, the gain value of t1 is about 1.9 and the gain value of t2 is about 1.7. Then, according to Formula (III) above, the contribution weight of t1 is about 1.9 and the contribution weight of t2 is about 1.07, which clearly shows that t1 has a higher value contribution as a round with "high score + high ranking".
[0068] Step 203: Determine the second relevance between the candidate historical conversation and the current query based on the contribution weight of each candidate conversation round in the group.
[0069] In one embodiment, determining the second relevance between a candidate historical session and the current query based on the contribution weight of each candidate dialogue round in the group includes: determining the sum of the contribution weights of all candidate dialogue rounds in the group as the second relevance between the candidate historical session and the current query.
[0070] The core logic of this embodiment is that "the sum of the values of all candidate dialogue rounds within a group represents the overall matching degree between the session and the current query." This approach is intuitive, computationally inexpensive, and suitable for scenarios requiring high retrieval efficiency where all candidate dialogue rounds within a group possess a certain degree of relevance. The specific implementation process is as follows: For a candidate historical session group defined in step 102, the contribution weight of each candidate dialogue round within that group is first calculated in step 202. Then, these contribution weights are "numerically summed," and the final sum represents the second relevance between the candidate historical session and the current query. For example, if a candidate historical session group contains three candidate dialogue rounds with contribution weights of 0.92, 0.85, and 0.78 respectively, then the second relevance of that session is 0.92 + 0.85 + 0.78 = 2.55.
[0071] The core feature of this embodiment is "equal treatment of the value contribution of all candidate dialogue rounds in the group". Regardless of whether the round ranks higher or lower in the group, its contribution weight will be included in the total. There is no need to introduce additional complex priority screening or weight adjustment logic. It is easy to implement and runs quickly.
[0072] However, the applicable scenarios of the above embodiments may be limited: when all candidate dialogue rounds within a candidate historical session group are effectively associated with the current query (without obviously low-value or weakly related rounds), the summation result can better reflect the overall matching degree of the session; if there are some "marginal rounds" with low contribution weights within the group (such as rounds that are only indirectly associated with the query), the summation may cause the second relevance to be "diluted," failing to accurately highlight the value of the core rounds within the session. For example, if there are 5 rounds in the group, with 4 rounds having a contribution weight of 0.1 and 1 round having a contribution weight of 0.9, the summation result is 1.3, which is insufficient to reflect the characteristic that the core of the session relies on a single high-value round.
[0073] In this regard, the following embodiments are also provided: In another embodiment, see Figure 3 An exemplary implementation of determining the second relevance of candidate historical sessions to the current query based on the contribution weight of each candidate dialogue round in the group includes the following steps: Step 301: Sort the candidate dialogue rounds in the group in descending order of contribution weight.
[0074] Step 302: Determine the single strongest evidence value of the candidate historical session based on the contribution weight of the top N candidate dialogue rounds, and determine the multi-point cumulative evidence value of the candidate historical session based on the contribution weight of all candidate dialogue rounds in the group.
[0075] Step 303: Based on the strongest single-point evidence value and the cumulative evidence value across multiple points, obtain the second relevance between the candidate historical session and the current query.
[0076] In one embodiment, the second relevance between the candidate historical session and the current query is obtained based on the single strongest evidence value and the multi-point cumulative evidence value, including: determining the adaptive weight λ corresponding to the candidate historical session, and performing weighted fusion processing on the single strongest evidence value and the multi-point cumulative evidence value based on the adaptive weight λ to obtain the second relevance between the candidate historical session and the current query.
[0077] The weighted fusion process in the above embodiments can be expressed as the following formula: Formula (IV) Where N is a positive integer, The second most relevant term for historical sessions is s. The strongest single piece of evidence value for historical session s. For the multi-point cumulative evidence value of historical sessions s, Adaptive weights for historical sessions s.
[0078] For ease of understanding, steps 301 to 303 are explained uniformly below: First of all, in general Figure 3 The illustrated embodiment is a more refined advanced solution based on the above embodiments. Its core logic is to "emphasize both high-value single-point evidence within a session (such as 1 to 2 highly relevant rounds) and the cumulative association value of all candidate dialogue rounds, while dynamically balancing the proportion of the two through adaptive weights." It can handle scenarios where the distribution of relevance among candidate dialogue rounds within a group varies greatly (such as some sessions relying on single-point strong evidence and some sessions relying on the superposition of multiple weak evidence). The calculation accuracy of the second relevance between candidate historical sessions and the current query is significantly higher than that of the above embodiments.
[0079] Specifically, in step 301, the candidate dialogue rounds are sorted in descending order of contribution weight. The purpose is to quickly identify the "core rounds" within a group that contribute significantly to the conversation matching score, laying the foundation for extracting the "strongest single-point evidence value" in the subsequent steps. For example, if the contribution weights of rounds within a group are 0.95, 0.88, 0.72, 0.61, and 0.55, the sorted order is 0.95→0.88→0.72→0.61→0.55. The top N rounds (e.g., N=1 or N=3) are the high-value core rounds of that group.
[0080] Subsequently, in step 302, the "strongest single-point evidence value" and the "cumulative evidence value" are calculated. These two indicators quantify the "local strong value" and "overall relevance value" of the session matching, respectively. The strongest single-point evidence value (denoted as M(s)) refers to the contribution weight of the most valuable single turn among the "top N candidate dialogue turns" within the group, or the average / weighted average of the contribution weights of the top N turns. This is used to capture the strong evidence within the session that "most directly hits the core needs of the current query." For example, if the contribution weights of the top 3 dialogue turns are 0.95, 0.88, and 0.72 respectively, when N=1, the strongest single-point evidence value can be set to the maximum value of 0.95 (highlighting the "strongest single point"). When N=3, a weighted average of the contribution weights can be assigned according to the ranking (e.g., 0.95×0.6+0.88×0.3+0.72×0.1=0.911, taking into account the overall strength of the top N turns). The purpose of the single point of strongest evidence value is to avoid "multiple weak evidence points overlapping to cover up single point of strong evidence" (for example, if a conversation has only one round with a weight of 0.98, and the rest are all 0.1, the single point of evidence value can highlight the core value of that round).
[0081] The cumulative evidence value (denoted as D(s)) refers to the sum of the contribution weights of all candidate dialogue rounds within a group, used to capture the cumulative value of "multi-round collaborative related queries" within a session. For example, the sum of the contribution weights of 5 dialogue rounds within a group is 0.95 + 0.88 + 0.72 + 0.61 + 0.55 = 3.71. The purpose of the cumulative evidence value is to avoid "focusing only on single-point evidence while ignoring the aggregated value of multiple weak evidence" (e.g., if a session does not have extremely high-weight rounds, but has 5 medium-to-high-weight rounds of 0.7-0.8, the cumulative evidence value can reflect its overall matching degree).
[0082] Finally, in step 303, by introducing an "adaptive weight λ(s)", the proportions of the strongest single-point evidence value (M(s)) and the cumulative multi-point evidence value (D(s)) in the second correlation are dynamically adjusted, and the second correlation is finally calculated by weighted summation. The adaptive weight λ(s) is not a fixed value, but an adaptive value.
[0083] This embodiment addresses the shortcoming of the first embodiment, which "could not distinguish the distribution of evidence," by employing a "dual evidence + adaptive weighting" approach. It can accurately identify conversations that "rely on strong single-point evidence" (e.g., when a user queries "refund application portal," a conversation may only explicitly answer the question in one round, with the rest being irrelevant; in this case, λ increases, highlighting the single-point evidence), and also accurately evaluate conversations that "rely on cumulative multi-point evidence" (e.g., when a user queries "refund process," a conversation may answer the application, review, and payment stages in multiple rounds; in this case, λ decreases, highlighting cumulative evidence). Its applicable scenarios cover most complex long-term memory dialogue retrieval needs, and it is particularly suitable for scenarios where the relevance distribution of candidate dialogue rounds within a group is uneven (some strongly correlated, some weakly correlated), achieving a balance between "accuracy" and "adaptability."
[0084] Further, in one embodiment, the adaptive weight λ corresponding to the candidate historical session is determined in the following way: the relevant information density of the candidate historical session corresponding to the current query is determined based on the number of candidate dialogue rounds in the group and the total number of dialogue rounds in the candidate historical session corresponding to the group; the adaptive weight λ corresponding to the candidate historical session is determined based on the relevant information density; wherein, the adaptive weight λ is negatively correlated with the relevant information density.
[0085] Among them, the relevant information density of candidate historical sessions corresponding to the current query is an indicator that measures the "distribution density of rounds related to the current query (i.e., candidate dialogue rounds after grouping in step 102) in the overall session". The higher the density, the more rounds in the session are related to the current query, and the more concentrated the relevant information is; the lower the density, the more few rounds in the session are related to the current query, and the more sparse the relevant information is. Therefore, the calculation of the relevant information density (denoted as density(s)) of candidate historical sessions corresponding to the current query relies on two key data: one is the "number of candidate dialogue rounds" (denoted as m) corresponding to the session after grouping in step 102. s The second is the number of complete rounds in the conversation itself (denoted as L). s The specific calculation formula is as follows: Formula (5) For example, a conversation consists of 10 complete rounds (L s =10), of which 6 rounds were retrieved as candidate dialogue rounds (m s If the density of the relevant information for the current query is 0.6, then the density of the relevant information for this session is 0.6.
[0086] Furthermore, as an optional implementation, to transform the information density into an adaptive weight λ that meets the requirements, a nonlinear Sigmoid function is chosen as the mapping tool. This function can map any input to the [0,1] interval, and the sensitivity of λ to density changes can be flexibly controlled through hyperparameters, thereby adapting to the numerical characteristics of the "weight". The specific mapping formula is as follows: Formula (VI) In formula (VI), c and d are adjustable hyperparameters. d primarily controls the steepness of the mapping curve (taking a negative value ensures that λ is negatively correlated with density). The larger the absolute value of d, the more significant the fluctuations in λ will be caused by small changes in density. c controls the offset of the midpoint of the curve. The "critical information density" corresponding to λ=0.5 can be set by adjusting c. The determination path of these two parameters is flexible. They can be set directly based on domain prior knowledge (e.g., setting c=1.2 and d=-3.5), or the optimal values can be learned through training with labeled dialogue retrieval data.
[0087] Taking specific values as an example, if c=1.0 and d=-4.0, when density=0.2, λ≈0.55, which is biased towards a larger value; when density=0.7, λ≈0.14, which is biased towards a smaller value, which fits the logic that "high density results in small λ and low density results in large λ".
[0088] It should be noted that the above formula (vi) is merely an exemplary implementation of converting information density into adaptive weight λ. In practical applications, other nonlinear monotonic functions, such as piecewise linear functions, Tanh functions, or mapping tables based on data distribution percentiles, etc., can also be used. This application does not limit this.
[0089] In the technical solution provided in this application, the adjustment logic of λ, combined with different ranges of relevant information density, can accurately adapt to three typical scenarios: In high information density scenarios (e.g., density(s) ≥ 0.6), most rounds within a session are relevant. Over-reliance on single-point evidence can easily overlook the collaborative value of multiple rounds. In this case, λ decreases (e.g., 0.2~0.3), allowing the cumulative evidence value (D(s)) from multiple points to dominate the score. In low information density scenarios (e.g., density(s) ≤ 0.2), only a few rounds within a session are relevant. If the focus is on accumulating evidence, its value is easily diluted by irrelevant rounds. In this case, λ increases (e.g., 0.6~0.8), allowing the strongest single-point evidence value (M(s)) to dominate the score. In scenarios with moderate information density (e.g., 0.2 < density(s) < 0.6), the distribution of relevant and irrelevant rounds is balanced, and λ takes an intermediate value (e.g., 0.4~0.6) to balance the contributions of dual evidence.
[0090] This adaptive weight λ determination method based on relevant information density has the advantage of "scenario adaptability". Without manual intervention, λ can automatically adjust the proportion of dual evidence according to the actual distribution of relevant information in the session. This avoids the rigidity of a fixed weight "one-size-fits-all" approach and ensures that the second relevance performance accurately reflects the matching essence of different types of sessions, providing a more reliable quantitative basis for subsequent target session recall.
[0091] Figure 2 The process shown is in Figure 1 Based on the illustrated process, a unified quantitative system that simultaneously reflects both "semantic matching strength" and "relative importance within a group" is constructed by combining primary relevance with in-session ranking and using gain functions and ranking depreciation factors to calculate contribution weights. This dual-dimensional fusion strategy significantly improves the discriminative power of value assessment: it can effectively distinguish the value differences between rounds with similar scores but different rankings, and accurately capture the importance gap between rounds with adjacent rankings but significantly different scores. Finally, based on these finely calculated contribution weights, session-level relevance scoring is performed, making the overall matching degree assessment of the session more accurate and robust. This lays a solid foundation for subsequent retrieval of high-quality target sessions and improves the overall accuracy and reliability of long-term dialogue memory retrieval.
[0092] Figure 4 A flowchart illustrating another example of a question-and-answer processing method provided in this application. Figure 4 The illustrated process, based on the above process, describes an exemplary implementation of retrieving target session content from the historical session database according to a second relevance. For example... Figure 4 As shown, it includes the following steps: Step 401: Sort the multiple candidate historical sessions according to their respective second relevance.
[0093] Step 402: Based on the sorting results, determine the target session from multiple candidate historical sessions.
[0094] In step 401, based on the "second relevance" calculated above, all candidate historical sessions are sorted to provide a clear priority basis for subsequent selection of target sessions.
[0095] In step 402, based on the sorting results of step 401, target sessions that are "most supportive of downstream responses" are extracted from the candidate historical sessions. The specific filtering logic can be combined with the needs of the actual application scenario. For example, the top M candidate sessions after sorting are selected as target sessions (M is a preset positive integer, such as M=3 or M=5. In practical applications, this can balance "information coverage" and "subsequent processing costs" to avoid redundancy caused by M being too large). For example, a minimum threshold for the second relevance is set (such as a threshold of 1.5), and only candidate historical sessions with scores higher than this threshold are listed as target sessions (suitable for scenarios with extremely high recall accuracy requirements, such as order dispute consultations by enterprise customer service, where low-matching sessions need to be strictly excluded).
[0096] Regardless of the method used, the "target session" is essentially the core object used to extract historical context in subsequent steps. It is the set of sessions with the highest matching degree to the current query, and all subsequent content retrieval operations revolve around the target session.
[0097] Step 403: Determine the relevant information density of the target session corresponding to the current query based on the number of candidate dialogue rounds in the target session and the total number of dialogue rounds in the target session.
[0098] For a detailed description of this step, please refer to the relevant descriptions in the above embodiments, which will not be repeated here.
[0099] Step 404: Retrieve the target session content from the target session based on the relevant information density.
[0100] In one embodiment, retrieving target session content from a target session based on relevant information density includes: retrieving all dialogue turns in the target session as target session content when the relevant information density is greater than a first preset threshold; retrieving a first candidate dialogue turn in the target session as target session content when the relevant information density is less than a second preset threshold, or retrieving the first candidate dialogue turn and its context dialogue turn as target session content; wherein the first candidate dialogue turn corresponds to the highest first relevance, and the second preset threshold is less than the first preset threshold; and retrieving multiple second candidate dialogue turns in the target session as target session content when the relevant information density is not less than the second preset threshold and not greater than the first preset threshold, or retrieving each second candidate dialogue turn and its context dialogue turn as target session content; wherein the first relevance corresponding to the second candidate dialogue turn satisfies a set condition.
[0101] The above embodiment uses a "differentiated recall strategy" to extract content from the target session based on the relevant information density calculated in step 403. This ensures that the recalled information meets the current query requirements while avoiding the introduction of redundant and irrelevant content. Specifically: In scenarios where "the density of relevant information is greater than a first preset threshold," it indicates that most rounds within the target session are relevant to the current query. In this case, all dialogue rounds within the target session are retrieved as content for the target session. This full retrieval logic stems from the fact that the overall context of the session is coherent and valuable; full retrieval avoids missing key details and provides sufficient support for generating a complete response downstream.
[0102] In scenarios where "the relevant information density is less than the second preset threshold", it indicates that only a few rounds in the target session are relevant to the query. In this case, it is necessary to focus on the core relevant rounds and adopt two retrieval methods: First, "retrieve the first candidate dialogue round in the target session" (the first candidate dialogue round is the round with the "highest first relevance" in the target session) and extract only the most core information; Second, "retrieve the first candidate dialogue round and its context dialogue rounds" (such as the round before and the round after the first candidate dialogue round), which not only retains the core information but also supplements the interaction scenario of the round, avoiding information fragmentation.
[0103] In a medium-density scenario where "the relevant information density is not less than the second preset threshold and not greater than the first preset threshold", it indicates that the distribution of relevant rounds within the target session is balanced (e.g., 4 out of 10 rounds are relevant). In this case, multiple high-value rounds can be recalled in two ways: First, "recall multiple second candidate dialogue rounds in the target session" (second candidate dialogue rounds are rounds where "the first relevance meets the set conditions", such as the first 3 high-scoring rounds or rounds with a score ≥ 0.8); second, "recall each second candidate dialogue round and its context", which covers multiple core information points and ensures the semantic integrity of each information point through context.
[0104] The advantage of this embodiment lies in "on-demand recall," which dynamically adjusts the recall granularity based on the relevant information density. This avoids the problems of "missed details" in high-density scenarios and "redundant interference" in low-density scenarios. Furthermore, it solves the semantic fragmentation of isolated rounds through contextual supplementation, providing high-quality historical context support for downstream generation of accurate and coherent responses.
[0105] Figure 4 The illustrated embodiment, building upon the above embodiments, effectively overcomes the inherent deficiency of single retrieval granularity in existing technologies by introducing a hierarchical recall mechanism based on relevant information density, achieving an optimal balance between recall content accuracy and contextual completeness. Specifically, it calculates the relevant information density of the target session and dynamically selects whether to recall the complete session, key rounds, or key rounds and their context, achieving intelligent adaptation of recall granularity. This differentiated strategy significantly reduces noise input to the downstream generative model, enhancing the system's task adaptability and enabling it to automatically respond to different scenarios.
[0106] Finally, this application also provides the following embodiments: after determining the second relevance between the candidate historical sessions corresponding to the group and the current query based on the first relevance of each candidate dialogue round in the group, it further includes: normalizing the second relevance based on the number of all dialogue rounds in the candidate historical sessions corresponding to the group; and performing the steps of recalling the target session content from the historical session database and subsequent steps based on the normalized second relevance.
[0107] The normalization step introduced in this embodiment aims to eliminate potential biases in the second relevance caused by differences in the length of the sessions themselves, thereby improving the fairness and accuracy of the ranking results. Specifically, after calculating the session-level second relevance using the dynamic fusion strategy described in the above embodiment, the original total length of the candidate historical session is further obtained, i.e., the total number of all dialogue rounds it contains, and the second relevance is normalized accordingly.
[0108] The underlying logic of this approach is that a longer session, simply because it contains more rounds, is statistically more likely to match multiple relevant segments, thus naturally resulting in a higher cumulative evidence value. However, this does not necessarily mean that the session is more relevant to the current query or that the information is more concentrated. For example, a long session with 50 rounds, including 3 moderately relevant rounds, may have a higher raw score than a short session with only 10 rounds but 1 extremely highly relevant round. Without normalization, the system is likely to tend to recall lengthy sessions that may contain a lot of irrelevant information, thereby introducing noise into the downstream generative model.
[0109] Therefore, by normalizing the second relevance based on the total session length, the relevance score of short sessions in the above example will be significantly improved, thus occupying a more advantageous position in the final ranking, while the relevance score of long sessions in the above example will decrease accordingly. This makes the system's recall strategy more intelligent, able to prioritize historical sessions with high information density, concise content, and a closer match to the core intent of the current query, regardless of their length.
[0110] Ultimately, the subsequent recall and generation steps will be performed based on a normalized, more comparable second relevance. This ensures that the "target session content" input into the response model is not only relevant but also efficient and low-noise, improving the accuracy and efficiency of the final response generation.
[0111] For example, the second correlation is normalized using the following formula: Formula (VII) In the above formula, The second correlation is after normalization. The second correlation before normalization. The length of the session, i.e., the total number of dialogue rounds it contains. It is a hyperparameter with a value range of [0,1], used to control the intensity of normalization.
[0112] It should be noted that the above formula (vii) is merely an exemplary implementation of normalizing the second correlation, and the embodiments of this application do not limit it.
[0113] Figure 5 This is a block diagram illustrating an embodiment of a question-and-answer processing device provided in this application. Figure 5 As shown, the device includes: The dialogue matching module 51 is used to respond to the current query by matching multiple candidate dialogue rounds related to the current query from the historical dialogue library, and determining a first relevance between each candidate dialogue round and the current query; The conversation matching module 52 is used to group the multiple candidate conversation rounds according to their respective conversations, and perform the following processing for each group: based on the first relevance of each candidate conversation round in the group, determine the second relevance between the candidate historical conversation corresponding to the group and the current query; The response module 53 is used to generate a response to the current query based on the second relevance.
[0114] In one possible implementation, the session matching module 52 includes: The first sorting unit is used to sort the candidate dialogue rounds in the group according to the first relevance from high to low, so as to obtain the relevance ranking of each candidate dialogue round in the group. The weight calculation unit is used to perform the following processing for each candidate dialogue round in the group: determine the contribution weight of the candidate dialogue round based on the first relevance and relevance ranking of the candidate dialogue round; The scoring calculation unit is used to determine the second relevance between the candidate historical session and the current query based on the contribution weight of each candidate dialogue round in the group.
[0115] In one possible implementation, the weight calculation unit is specifically used for: The first relevance of the candidate dialogue rounds is mapped to a gain value using a preset gain function; The relevance ranking of the candidate dialogue rounds and the gain value are set and calculated to obtain the contribution weight of the candidate dialogue rounds. Wherein, the gain value is positively correlated with the first correlation, the contribution weight is positively correlated with the gain value, and the contribution weight is negatively correlated with the correlation ranking.
[0116] In one possible implementation, the scoring calculation unit is specifically used for: The sum of the contribution weights of all candidate dialogue rounds in the group is determined as the second relevance between the candidate historical session and the current query.
[0117] In one possible implementation, the scoring calculation unit is specifically used for: Sort the candidate dialogue rounds in the group in descending order of contribution weight; The single strongest evidence value of the candidate historical session is determined based on the contribution weight of the top N candidate dialogue rounds. The multi-point cumulative evidence value of the candidate historical session is determined based on the contribution weight of all candidate dialogue rounds in the group. Based on the single strongest evidence value and the multi-point cumulative evidence value, the second relevance between the candidate historical session and the current query is obtained.
[0118] In one possible implementation, the scoring calculation unit obtains a second relevance between the candidate historical session and the current query based on the single strongest evidence value and the multi-point cumulative evidence value, including: Determine the adaptive weights corresponding to the candidate historical sessions; Based on the adaptive weights, the strongest single-point evidence value and the cumulative multi-point evidence value are weighted and fused to obtain the second relevance between the candidate historical session and the current query.
[0119] In one possible implementation, the scoring calculation unit determines the adaptive weights corresponding to candidate historical sessions, including: Based on the number of candidate dialogue rounds in the group and the number of all dialogue rounds in the candidate historical sessions corresponding to the group, the relevant information density of the candidate historical session corresponding to the current query is determined. The adaptive weights corresponding to the candidate historical sessions are determined based on the relevant information density. The adaptive weights are negatively correlated with the relevant information density.
[0120] In one possible implementation, the response module 53 includes: A session recall unit is used to recall target session content from the historical session database based on the second correlation. The model response unit is used to input the target session content and the current query into the response model to generate a response to the current query.
[0121] In one possible implementation, the session recall unit includes: The second sorting subunit is used to sort the multiple candidate historical sessions according to their respective second relevance; The target session determination subunit is used to determine the target session from the multiple candidate historical sessions based on the sorting results; The information density calculation subunit is used to determine the relevant information density of the target session corresponding to the current query based on the number of candidate dialogue rounds in the target session and the total number of dialogue rounds in the target session. The recall subunit is used to recall target session content from the target session based on the relevant information density.
[0122] In one possible implementation, the recall subunit is specifically used for: If the density of the relevant information is greater than a first preset threshold, all dialogue rounds in the target session will be recalled as target session content. If the relevant information density is less than a second preset threshold, the first candidate dialogue turn in the target session is recalled as the target session content, or the first candidate dialogue turn and the context dialogue turn of the first candidate dialogue turn are recalled as the target session content; wherein, the first candidate dialogue turn corresponds to the first relevance, and the second preset threshold is less than the first preset threshold. If the relevant information density is not less than the second preset threshold and not greater than the first preset threshold, multiple second candidate dialogue rounds in the target session are recalled as target session content, or each second candidate dialogue round and its context dialogue round are recalled as target session content; wherein, the first relevance corresponding to the second candidate dialogue round satisfies the set condition.
[0123] In one possible implementation, the device further includes: The normalization module is used to normalize the second correlation based on the number of all dialogue rounds in the candidate historical sessions corresponding to the group after determining the second correlation between the candidate historical sessions corresponding to the group and the current query based on the first correlation of each candidate dialogue round in the group.
[0124] like Figure 6 As shown in the figure, this application provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114. Memory 113 is used to store computer programs; In one embodiment of this application, when the processor 111 executes the program stored in the memory 113, it implements the question-and-answer processing method provided in any of the foregoing method embodiments, including: In response to the current query, multiple candidate conversation rounds related to the current query are matched from the historical conversation database, and a first relevance of each candidate conversation round to the current query is determined; The multiple candidate dialogue rounds are grouped according to their respective sessions, and the following processing is performed on each group: based on the first relevance of each candidate dialogue round in the group, the second relevance of the candidate historical session corresponding to the group and the current query is determined; Based on the second relevance, a response to the current query is generated.
[0125] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the question-and-answer processing method provided in any of the foregoing method embodiments.
[0126] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0127] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0128] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.
[0129] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A question and answer processing method characterized by, The method includes: In response to the current query, multiple candidate conversation rounds related to the current query are matched from the historical conversation database, and a first relevance of each candidate conversation round to the current query is determined; The multiple candidate dialogue rounds are grouped according to their respective sessions, and the following processing is performed on each group: based on the first relevance of each candidate dialogue round in the group, the second relevance of the candidate historical session corresponding to the group and the current query is determined; Based on the second relevance, a response to the current query is generated.
2. The method of claim 1, wherein, The step of determining the second relevance between the candidate historical sessions corresponding to the group and the current query based on the first relevance of each candidate dialogue round in the group includes: The candidate dialogue rounds in the group are sorted in descending order of their corresponding first relevance to obtain the relevance ranking of each candidate dialogue round in the group. For each candidate dialogue round in the group, the following processing is performed: the contribution weight of the candidate dialogue round is determined based on the first relevance and relevance ranking of the candidate dialogue round; Based on the contribution weight of each candidate dialogue round in the group, a second relevance between the candidate historical session and the current query is determined.
3. The method of claim 2, wherein, The step of determining the contribution weight of the candidate dialogue rounds based on the first relevance and relevance ranking of the candidate dialogue rounds includes: The first relevance of the candidate dialogue rounds is mapped to a gain value using a preset gain function; The relevance ranking of the candidate dialogue rounds and the gain value are set and calculated to obtain the contribution weight of the candidate dialogue rounds. Wherein, the gain value is positively correlated with the first correlation, the contribution weight is positively correlated with the gain value, and the contribution weight is negatively correlated with the correlation ranking.
4. The method of claim 2, wherein, The step of determining the second relevance between the candidate historical session and the current query based on the contribution weight of each candidate dialogue round in the group includes: The sum of the contribution weights of all candidate dialogue rounds in the group is determined as the second relevance between the candidate historical session and the current query.
5. The method of claim 2, wherein, The step of determining the second relevance between the candidate historical session and the current query based on the contribution weight of each candidate dialogue round in the group includes: Sort the candidate dialogue rounds in the group in descending order of contribution weight; The single strongest evidence value of the candidate historical session is determined based on the contribution weight of the top N candidate dialogue rounds. The multi-point cumulative evidence value of the candidate historical session is determined based on the contribution weight of all candidate dialogue rounds in the group. Based on the single strongest evidence value and the multi-point cumulative evidence value, the second relevance between the candidate historical session and the current query is obtained.
6. The method of claim 5, wherein, The step of obtaining the second relevance between the candidate historical session and the current query based on the single strongest evidence value and the multi-point cumulative evidence value includes: Determine the adaptive weights corresponding to the candidate historical sessions; Based on the adaptive weights, the strongest single-point evidence value and the cumulative multi-point evidence value are weighted and fused to obtain the second relevance between the candidate historical session and the current query.
7. The method of claim 6, wherein, The determination of the adaptive weights corresponding to candidate historical sessions includes: Based on the number of candidate dialogue rounds in the group and the number of all dialogue rounds in the candidate historical sessions corresponding to the group, the relevant information density of the candidate historical session corresponding to the current query is determined. The adaptive weights corresponding to the candidate historical sessions are determined based on the relevant information density. The adaptive weights are negatively correlated with the relevant information density.
8. The method of claim 1, wherein, The step of generating a response to the current query based on the second relevance includes: Based on the second correlation, the target session content is retrieved from the historical session database; The target session content and the current query are input into the response model to generate a response to the current query.
9. The method of claim 8, wherein, The step of retrieving target session content from the historical session database based on the second correlation includes: The candidate historical sessions are sorted according to their respective second relevance; Based on the sorting results, the target session is determined from the multiple candidate historical sessions; Based on the number of candidate dialogue rounds in the target session and the total number of dialogue rounds in the target session, the relevant information density of the target session corresponding to the current query is determined; Based on the relevant information density, retrieve the target session content from the target session.
10. The method of claim 9, wherein, The step of retrieving target session content from the target session based on the relevant information density includes: If the density of the relevant information is greater than a first preset threshold, all dialogue rounds in the target session will be recalled as target session content. If the relevant information density is less than a second preset threshold, the first candidate dialogue turn in the target session is recalled as the target session content, or the first candidate dialogue turn and the context dialogue turn of the first candidate dialogue turn are recalled as the target session content; wherein, the first candidate dialogue turn corresponds to the first relevance, and the second preset threshold is less than the first preset threshold. If the relevant information density is not less than the second preset threshold and not greater than the first preset threshold, multiple second candidate dialogue rounds in the target session are recalled as target session content, or each second candidate dialogue round and its context dialogue round are recalled as target session content; wherein, the first relevance corresponding to the second candidate dialogue round satisfies the set condition.
11. The method according to claim 1, characterized in that, After determining the second relevance between the candidate historical sessions corresponding to the group and the current query based on the first relevance of each candidate dialogue round in the group, the method further includes: The second correlation is normalized based on the number of all dialogue rounds in the candidate historical sessions corresponding to the group. The steps of retrieving the target session content from the historical session database and subsequent steps are performed based on the second correlation after normalization processing.
12. A question-and-answer processing device, characterized in that, The device includes: The dialogue matching module is used to respond to the current query by matching multiple candidate dialogue rounds related to the current query from the historical dialogue database, and determining a first relevance between each candidate dialogue round and the current query; The session matching module is used to group the multiple candidate dialogue rounds according to their respective sessions, and perform the following processing for each group: determine the second relevance between the candidate historical session corresponding to the group and the current query based on the first relevance of each candidate dialogue round in the group; The response module is used to generate a response to the current query based on the second relevance.