Vector retrieval method and device, computer equipment and storage medium

By constructing target dialogue data and optimizing the encoder model using supervised learning and reinforcement learning, the problem of insufficient correlation of vector retrieval methods in the existing technology is solved, and more efficient completion and accuracy of dialogue tasks are achieved.

CN118568501APending Publication Date: 2024-08-30ZHONGAN ONLINE P&C INSURANCE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410697724.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing vector retrieval methods are mainly based on artificially set semantic relationships and cannot be directly related to the goals of the final application scenario, resulting in retrieval results that do not meet actual needs, especially in sales scenarios where tasks cannot be effectively completed.

Method used

By constructing target dialogue data, using a combination of supervised learning and reinforcement learning, different encoder models are trained, and reward models and policy models are used to optimize the encoder models to improve the accuracy of vector retrieval and completion of dialogue tasks.

Benefits of technology

It improves the accuracy of vector retrieval and the completion rate of dialogue tasks. It can correctly understand the context, provide retrieval results that are most beneficial to the task goal, and improve the understanding and completion of multiple rounds of dialogue.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568501A
    Figure CN118568501A
Patent Text Reader

Abstract

The invention relates to a vector retrieval method and device, computer equipment and a storage medium, and the method comprises the steps: constructing training data based on collected target dialogue data, the training data at least comprising respective expression data sets Xi and yi of two dialogue parties; training the training data in a supervised learning mode to obtain a first encoder model of an Xi text steering vector and a second encoder model of a yi text steering vector, wherein the first encoder model and the second encoder model are different encoder models; updating the first encoder model and the second encoder model based on a reward model and an optimization strategy model to obtain a target encoder model; performing vector retrieval based on the target encoder model; the problem that only semantic relations are considered in current vector retrieval is solved, retrieval based on context understanding in multiple rounds of dialogues is solved, and the completion degree of dialogue tasks is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of text processing, and in particular to a vector retrieval method, device, computer equipment and storage medium. Background Art

[0002] With the development of large language models, Retrieval Augmented Generation (RAG) has become an effective method for applying large language models. The retrieval part usually uses the vector retrieval method. There are three main methods for training text vectors:

[0003] 1. By constructing text pair corpora, such as similar text pairs, inference relationship text pairs, question-answer text pairs, etc., the text vector is trained through the dual-tower structure Encoder model; 2. Constructing category text data and training through Metric Learning; 3. Comparative learning.

[0004] However, all methods are based on some artificially set semantic relationship between texts, which has no direct correlation with the goal of the final application scenario. For example, the content of the sales scenario RAG may not be conducive to the completion of the final sales task goal. Therefore, we need a result-oriented vector retrieval method, not just the semantic similarity of FAQ (Frequently Asked Questions). Summary of the invention

[0005] Based on this, it is necessary to provide a vector retrieval method, device, computer equipment and storage medium that can improve the accuracy of vector retrieval and improve the completion of dialogue tasks in response to the above technical problems.

[0006] In a first aspect, a vector retrieval method is provided, the method comprising:

[0007] The training data is constructed based on the collected target dialogue data, and the training data at least includes the expression data set X of each of the dialogue parties. i ,y i ;

[0008] The training data is trained by supervised learning to obtain X i The first encoder model of the text turn quantity is y i a second encoder model for a text steering amount, wherein the first encoder model and the second encoder model are different encoder models;

[0009] Based on the reward model and the optimization strategy model, the first encoder model and the second encoder model are updated to obtain a target encoder model;

[0010] Vector retrieval is performed based on the target encoder model.

[0011] In a preferred embodiment, the updating of the first encoder model and the second encoder model based on the reward model and the optimization strategy model to obtain the target encoder model includes:

[0012] Setting a strategy model formula based on the training data, the first encoder model, and the second encoder model;

[0013] Based on the actual completion of the dialogue task, the first encoder and the second encoder are trained until the loss function is within a preset range to obtain a target encoder model.

[0014] In a preferred embodiment, the strategy model formula is set based on the training data, the first encoder model and the second encoder model, including:

[0015] Defining the Strategy Model Formula in,

[0016] θ is the parameter of the policy model π, S t , α t are the state and action at time t respectively, and sim represents the similarity calculation method between vectors;

[0017] Calculate a target vector set based on the training data and the first encoder and the second encoder;

[0018] Sampling is performed based on the target vector set and calculation is performed based on the strategy model formula.

[0019] In a preferred embodiment, the step of calculating a target vector set based on the training data and the first encoder and the second encoder includes:

[0020] Using the conversation data of the answering party in the target conversation data as a behavior candidate set;

[0021] Calculate the behavior candidate set based on the second encoder to obtain a behavior vector set;

[0022] The data set X is calculated based on the first encoder i Obtain a first vector set;

[0023] The vectors corresponding to the first vector set in the behavior vector set are removed to obtain a target vector set.

[0024] In a preferred embodiment, the sampling based on the target vector set and the calculation based on the strategy model formula include:

[0025] A preset number of vectors are sampled from the target vector set based on a preset formula, and the vectors are merged and substituted into the strategy model formula for calculation.

[0026] In a preferred embodiment, the training of the first encoder and the second encoder based on the actual completion of the dialogue task until the loss function is within a preset range to obtain a target encoder model includes:

[0027] The dialogue sample data is marked based on the actual completion of the dialogue task to obtain a first data set;

[0028] Counting the number of conversation rounds of each conversation sample, and obtaining a second data set based on the number of conversation rounds;

[0029] Integrate the first data set and the second data set based on a preset rule to obtain a target training data set;

[0030] Calculate a sample loss function based on the target training data set;

[0031] The first encoder and the second encoder are trained until the loss function is within a preset range to obtain a target encoder model.

[0032] In a preferred embodiment, counting the number of conversation turns of each conversation sample and obtaining the second data set based on the number of conversation turns sampling comprises:

[0033] Count the number of dialogue turns t for each dialogue sample i +1;

[0034] Sampling acquisition (t i +1) / 2 to t i +1 integer P i ;

[0035] The conversation sample data sequence is truncated according to the integer Pi to obtain a second data set.

[0036] In a second aspect, the present invention provides a vector search device, the device comprising:

[0037] A construction module, used to construct training data based on the collected target dialogue data, wherein the training data at least includes the expression data sets Xi, yi of the two dialogue parties;

[0038] A first training module is used to train the training data by supervised learning to obtain a first encoder model of the Xi text steering amount and a second encoder model of the Yi text steering amount, wherein the first encoder model and the second encoder model are different encoder models;

[0039] A second training module, used for updating the first encoder model and the second encoder model based on the reward model and the optimization strategy model to obtain a target encoder model;

[0040] An execution retrieval module is used to execute vector retrieval based on the target encoder model.

[0041] In a third aspect, the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:

[0042] The training data is constructed based on the collected target dialogue data, and the training data at least includes the expression data set X of each of the dialogue parties. i ,y i ;

[0043] The training data is trained by supervised learning to obtain X i The first encoder model of the text turn quantity is y i a second encoder model for a text steering amount, wherein the first encoder model and the second encoder model are different encoder models;

[0044] Based on the reward model and the optimization strategy model, the first encoder model and the second encoder model are updated to obtain a target encoder model;

[0045] Vector retrieval is performed based on the target encoder model.

[0046] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0047] The training data is constructed based on the collected target dialogue data, and the training data at least includes the expression data set X of each of the dialogue parties. i ,y i ;

[0048] The training data is trained by supervised learning to obtain X i The first encoder model of the text turn quantity is y i a second encoder model for a text steering amount, wherein the first encoder model and the second encoder model are different encoder models;

[0049] Based on the reward model and the optimization strategy model, the first encoder model and the second encoder model are updated to obtain a target encoder model;

[0050] Vector retrieval is performed based on the target encoder model.

[0051] The above-mentioned vector retrieval method, apparatus, computer device and storage medium, the method comprises: constructing training data based on the collected target dialogue data, the training data at least comprising the expression data set X of each of the dialogue parties i ,yi ; Train the training data by supervised learning to obtain X i The first encoder model of the text turn quantity is y i A second encoder model for text steering, the first encoder model and the second encoder model are different encoder models; based on the reward model and the optimization strategy model, the first encoder model and the second encoder model are updated to obtain a target encoder model; vector retrieval is performed based on the target encoder model; the first encoder model and the second encoder model required for subsequent reinforcement learning are obtained through supervised learning fine-tuning. Subsequently, in the reinforcement learning stage, the reward model is first trained, and then the first encoder model and the second encoder model are updated according to the steps described in the optimization strategy model, which solves the problem of only considering semantic relationships in current vector retrieval, and solves the retrieval based on context understanding in multi-round dialogues, and the dialogue task completion degree is higher. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 is a schematic flow chart of a vector retrieval method in one embodiment;

[0053] Figure 2 Schematic diagram of a process flow of a supervised learning fine-tuning part in a vector retrieval method in one embodiment;

[0054] Figure 3 A schematic flow chart of the steps of updating the first encoder model and the second encoder model in a vector retrieval method in one embodiment;

[0055] Figure 4 is a structural block diagram of a vector retrieval device in one embodiment;

[0056] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0057] As described in the background art, current language processing retrieval dialogue methods are all based on certain artificially set semantic relationships between texts, and have no direct relevance to the goals of the final application scenario.

[0058] For example: Bot: Hello! I am Xiao A from Company A. I saw that you browsed our Company A's outpatient and emergency medical insurance this afternoon. Do you still remember it?

[0059] User: No image

[0060] Retrieval response that only considers semantics: "Sir, my system shows that you browsed through the A company app at 3 pm today..." Obviously, the answers provided by the current vector retrieval cannot meet the needs of users. To solve the above problems, the present invention provides a vector retrieval method, device, computer equipment and storage medium, which obtains the first encoder model and the second encoder model required for subsequent reinforcement learning through supervised learning fine-tuning. In the subsequent reinforcement learning stage, the reward model is first trained, and then the first encoder model and the second encoder model are updated according to the steps described in the optimization strategy model, which solves the problem of only considering semantic relationships in the current vector retrieval, and solves the retrieval based on context understanding in multiple rounds of dialogue, and the dialogue task completion degree is higher.

[0061] In actual applications, such as in the previous dialogue, this method retrieves the reply: "Let me explain to you, this insurance covers reasonable and necessary treatment expenses for any accident or illness in any public hospital at or above the second level in the country..." The test results show that this method has a higher task completion rate. Without context, the user's semantics cannot be understood in some cases, such as when the user asks "What do you mean?". This method can give the most favorable search results for the task goal after correctly understanding the context.

[0062] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0063] The vector retrieval method provided by the present application, in one embodiment, is as follows: Figure 1 As shown, a vector retrieval method is provided, comprising the following steps:

[0064] S110: construct training data based on the collected target dialogue data, wherein the training data at least includes a set of expression data X of each of the dialogue parties. i ,y i .X i is the initiator of the conversation, y i For the responder.

[0065] Specifically, collect conversation data related to the conversation task:

[0066] Among them, x0 and y0 are the statements of the two parties in the dialogue, X i =(x0,y0,x1,y1…x i ), and build training data X on this basis i ,y i .

[0067] S120, train the training data by supervised learning to obtain Xi The first encoder model of the text turn quantity is y i The second encoder model of the text steering quantity, the first encoder model and the second encoder model are different encoder models.

[0068] Reference Figure 2 As shown, through supervised learning, training obtains X i Encoder model for text steering x and X i ,y i Encoder y , X i ,y i Use different encoding models.

[0069] S130. Update the first encoder model and the second encoder model based on the reward model and the optimization strategy model to obtain a target encoder model.

[0070] This method supports multiple policy optimization algorithms including but not limited to Policy Gradient (PG), Trust Region Policy Optimization (TRPO), Proximal Policy Optimization (PPO), etc.

[0071] Specifically, this step includes:

[0072] S131. Setting a strategy model formula based on the training data, the first encoder model, and the second encoder model.

[0073] Specifically include:

[0074] S1311. Define the strategy model formula

[0075]

[0076] Among them, θ is the parameter of the policy model π, S t , α t are the state and action at time t respectively. sim represents the similarity calculation method between vectors, such as cosine similarity, dot product, etc. T is the temperature parameter. The calculation method of sim must be consistent with the first stage method.

[0077] S1312. Obtain a target vector set based on the training data and the first encoder and the second encoder.

[0078] Reference Figure 3 As shown, all the answer corpus in the task dialogue is collected. The answer corpus is the dialogue data of the answering party:

[0079] (1) The conversation data of the answering party in the target conversation data is used as a behavior candidate set.

[0080] Specifically, y in the first stage S110 is collected as the behavior candidate set φy.

[0081] (2) Calculating the behavior candidate set based on the second encoder to obtain a behavior vector set.

[0082] Specifically, use Encoder 计 Calculate the candidate set φy to obtain the behavior vector set φV.

[0083] (3) Calculate the data set X based on the first encoder i Get the first vector set.

[0084] Specifically, using Encoder x Calculate X i Vector Get the first vector set.

[0085] (4) Filter out the vectors corresponding to the first vector set from the behavior vector set to obtain a target vector set.

[0086] Specifically, remove y from the behavior vector set φV i The corresponding vector Get the target vector set

[0087] S1313: Sampling based on the target vector set and performing calculation based on the strategy model formula.

[0088] This step specifically includes: sampling a preset number of vectors from the target vector set based on a preset formula, and merging and substituting them into the strategy model formula for calculation.

[0089] Specifically, k-1 samples satisfying the following formula (2) are sampled from the answer corpus, that is, from the target vector set According to the following formula (2), k-1 vectors are sampled Finally merge the vectors Calculated according to the strategy model formula (1).

[0090] The sampling vector should meet the following conditions:

[0091]

[0092] Where m>0.

[0093] S132: Based on the actual completion of the dialogue task, train the first encoder and the second encoder until the loss function is within a preset range to obtain a target encoder model.

[0094] Specifically, there are two key steps in the training of the reward model f(x): training samples and loss function.

[0095] This step includes:

[0096] S1321. Based on the actual completion status of the dialogue task, the dialogue sample data is labeled to obtain a first data set.

[0097] Reference Figure 3 As shown, the task completion status in the dialogue task is marked. Specifically, the dialogue sample data is marked according to the actual dialogue task completion status. Tagging i , the task is completed i =1, otherwise 0, thus obtaining the first data set

[0098] S1322. Count the number of dialogue turns of each dialogue sample, and obtain a second data set based on the number of dialogue turns.

[0099] The dialogue samples are truncated and sorted according to the task completion degree D>B, A<C. Specifically, the number of dialogue turns t of each dialogue sample is counted i +1, sampling obtains (ti+1) / / 2 to (t i +1) i According to p i Session Sequence Truncate, Thus, the second data set is obtained

[0100] S1323: Integrate the first data set and the second data set based on a preset rule to obtain a target training data set.

[0101] Specifically, integrate according to the following preset rules and Get the training data set D:

[0102] Get and its corresponding truncated sequence If its corresponding l i =1, then the training sample is obtained Otherwise, it is ignored;

[0103] For l i =1 for each and From l i =0 and K samples are sampled from the data set Get training samples This is the target training data set.

[0104] S1324. Calculate a sample loss function based on the target training data set.

[0105] The reward model RM is trained using the data obtained above. The main goal of the reward model is to evaluate the consistency of the model's response with human preferences. The input of the RM model is questions and answers, and the output is a scalar reward value, i.e., score. The goal of training the reward model is to make the scalar score corresponding to the high-ranked answer higher than the scalar score corresponding to the low-ranked answer, and the higher the better, that is, to make the difference in the loss function as large as possible.

[0106] Specifically: Sample (τ A >τ B )The corresponding loss function is:

[0107] loss=-∑log(sigmoid(f(A)-f(B)) (3)

[0108] S1325. Train the first encoder and the second encoder until the loss function is within a preset range to obtain a target encoder model.

[0109] Sample the corpus of the historical conversation initiator from the conversation data, input the corpus of the conversation initiator into the encoder model, use the policy model formula (1) to calculate the probability output of the answer corpus corresponding to the corpus of the conversation initiator, input the corpus of the conversation initiator and the corresponding answer corpus into the reward model for calculation, use the reward model to calculate the reward value of the input corpus of the conversation initiator and the corresponding answer corpus, and evaluate the corresponding answer corpus. Use the policy gradient algorithm, that is, the steps described in the above policy model, to optimize the policy model, i.e., Encoder C and Encoder A Get the target encoder model. The policy gradient algorithm is a reinforcement learning method that directly optimizes the policy. It represents the policy as a continuous function related to the reward, and then uses the gradient ascent method to find the optimal policy parameters to maximize the cumulative reward value.

[0110] The target encoder model provided in this embodiment first obtains the historical dialogue encoding model Encoder required for subsequent reinforcement learning through supervised learning fine-tuning. C and answer encoding model Encoder A In the reinforcement learning phase, first train the reward model, then update the Encoder as described in the optimization policy model. C and Encoder AThe target encoding model obtained can correctly understand the conversation context, solve the problem of only considering semantic relations in current vector retrieval, consider the problem from the perspective of completing the conversation goal (product sales, guiding operations, etc.), and sort the text expressions that are most conducive to completing the task goal to the front, thereby improving the completion rate of the conversation task.

[0111] S140, performing vector retrieval based on the target encoder model.

[0112] Specifically, use Encoder C and Encoder A Encode the request query and candidate answers, calculate the similarity between the query and the candidate answers, and sort them by similarity. The top 1 is the answer that is most conducive to task completion.

[0113] It should be understood that although Figure 1-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-3 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0114] In another embodiment, the present invention provides a vector search device, the device comprising:

[0115] A construction module 410 is used to construct training data based on the collected target dialogue data, wherein the training data at least includes the expression data sets Xi, yi of the two dialogue parties.

[0116] A first training module 420 is used to train the training data by supervised learning to obtain a first encoder model of the Xi text steering amount and a second encoder model of the Yi text steering amount, wherein the first encoder model and the second encoder model are different encoder models;

[0117] A second training module 430, configured to update the first encoder model and the second encoder model based on the reward model and the optimization strategy model to obtain a target encoder model;

[0118] The execution retrieval module 440 is used to perform vector retrieval based on the target encoder model.

[0119] In one embodiment, the second training module 430 includes:

[0120] A setting unit, configured to set a strategy model formula based on the training data, the first encoder model, and the second encoder model;

[0121] A training unit is used to train the first encoder and the second encoder based on the actual completion of the dialogue task until the loss function is within a preset range to obtain a target encoder model.

[0122] Preferably, the setting unit includes:

[0123] Define subunits for defining policy model formulas Among them, θ is the parameter of the policy model π, S t , α t are the state and action at time t respectively, and sim represents the similarity calculation method between vectors;

[0124] A first calculation subunit, configured to calculate a target vector set based on the training data and the first encoder and the second encoder;

[0125] The sampling and calculation subunit is used to sample based on the target vector set and perform calculation based on the strategy model formula.

[0126] More preferably, the first computing subunit is specifically used for:

[0127] Using the conversation data of the answering party in the target conversation data as a behavior candidate set;

[0128] Calculate the behavior candidate set based on the second encoder to obtain a behavior vector set;

[0129] The data set X is calculated based on the first encoder i Obtain a first vector set;

[0130] The vectors corresponding to the first vector set in the behavior vector set are removed to obtain a target vector set.

[0131] More preferably, the sampling calculation subunit is specifically used for:

[0132] A preset number of vectors are sampled from the target vector set based on a preset formula, and the vectors are merged and substituted into the strategy model formula for calculation.

[0133] More preferably, the training unit comprises:

[0134] An identification subunit, used for identifying the dialogue sample data based on the actual dialogue task completion status to obtain a first data set;

[0135] A statistical sampling subunit, used for counting the number of dialogue turns of each dialogue sample, and obtaining a second data set based on the number of dialogue turns;

[0136] An integration subunit, configured to integrate the first data set and the second data set based on a preset rule to obtain a target training data set;

[0137] A second calculation subunit, used to calculate a sample loss function based on the target training data set;

[0138] A training subunit is used to train the first encoder and the second encoder until the loss function is within a preset range to obtain a target encoder model.

[0139] More preferably, the statistical sampling subunit is used for:

[0140] Count the number of dialogue turns t for each dialogue sample i +1;

[0141] Sampling acquisition (t i +1) / 2 to t i +1 integer P i ;

[0142] The conversation sample data sequence is truncated according to the integer Pi to obtain a second data set.

[0143] For the specific definition of the vector retrieval device, please refer to the definition of the vector retrieval method above, which will not be repeated here. Each module in the above-mentioned vector retrieval device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0144] In another embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a vector retrieval method is implemented.

[0145] Those skilled in the art will understand that Figure 5The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0146] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:

[0147] The training data is constructed based on the collected target dialogue data, and the training data at least includes the expression data set X of each of the dialogue parties. i ,y i ;

[0148] The training data is trained by supervised learning to obtain X i The first encoder model of the text turn quantity is y i a second encoder model for a text steering amount, wherein the first encoder model and the second encoder model are different encoder models;

[0149] Based on the reward model and the optimization strategy model, the first encoder model and the second encoder model are updated to obtain a target encoder model;

[0150] Vector retrieval is performed based on the target encoder model.

[0151] When the processor executes the computer program, the following steps are also implemented:

[0152] Setting a strategy model formula based on the training data, the first encoder model, and the second encoder model;

[0153] Based on the actual completion of the dialogue task, the first encoder and the second encoder are trained until the loss function is within a preset range to obtain a target encoder model.

[0154] When the processor executes the computer program, the following steps are also implemented:

[0155] Defining the Strategy Model Formula in,

[0156] θ is the parameter of the policy model π, S t , α t are the state and action at time t respectively, and sim represents the similarity calculation method between vectors;

[0157] Calculate a target vector set based on the training data and the first encoder and the second encoder;

[0158] Sampling is performed based on the target vector set and calculation is performed based on the strategy model formula.

[0159] When the processor executes the computer program, the following steps are also implemented:

[0160] Using the conversation data of the answering party in the target conversation data as a behavior candidate set;

[0161] Calculate the behavior candidate set based on the second encoder to obtain a behavior vector set;

[0162] The data set X is calculated based on the first encoder i Obtain a first vector set;

[0163] The vectors corresponding to the first vector set in the behavior vector set are removed to obtain a target vector set.

[0164] When the processor executes the computer program, the following steps are also implemented:

[0165] A preset number of vectors are sampled from the target vector set based on a preset formula, and the vectors are merged and substituted into the strategy model formula for calculation.

[0166] When the processor executes the computer program, the following steps are also implemented:

[0167] The dialogue sample data is marked based on the actual completion of the dialogue task to obtain a first data set;

[0168] Counting the number of conversation rounds of each conversation sample, and obtaining a second data set based on the number of conversation rounds;

[0169] Integrate the first data set and the second data set based on a preset rule to obtain a target training data set;

[0170] Calculate a sample loss function based on the target training data set;

[0171] The first encoder and the second encoder are trained until the loss function is within a preset range to obtain a target encoder model.

[0172] When the processor executes the computer program, the following steps are also implemented:

[0173] Count the number of dialogue turns t for each dialogue sample i +1;

[0174] Sampling acquisition (t i +1) / 2 to t i +1 integer P i ;

[0175] The conversation sample data sequence is truncated according to the integer Pi to obtain a second data set.

[0176] In another embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0177] The training data is constructed based on the collected target dialogue data, and the training data at least includes the expression data set X of each of the dialogue parties. i ,y i ;

[0178] The training data is trained by supervised learning to obtain X i The first encoder model of the text turn quantity is y i a second encoder model for a text steering amount, wherein the first encoder model and the second encoder model are different encoder models;

[0179] Based on the reward model and the optimization strategy model, the first encoder model and the second encoder model are updated to obtain a target encoder model;

[0180] Vector retrieval is performed based on the target encoder model.

[0181] When the computer program is executed by a processor, the following steps are also implemented:

[0182] Setting a strategy model formula based on the training data, the first encoder model, and the second encoder model;

[0183] Based on the actual completion of the dialogue task, the first encoder and the second encoder are trained until the loss function is within a preset range to obtain a target encoder model.

[0184] When the computer program is executed by a processor, the following steps are also implemented:

[0185] Defining the Strategy Model Formula in,

[0186] θ is the parameter of the policy model π, S t , α t are the state and action at time t respectively, and sim represents the similarity calculation method between vectors;

[0187] Calculate a target vector set based on the training data and the first encoder and the second encoder;

[0188] Sampling is performed based on the target vector set and calculation is performed based on the strategy model formula.

[0189] When the computer program is executed by a processor, the following steps are also implemented:

[0190] Using the conversation data of the answering party in the target conversation data as a behavior candidate set;

[0191] Calculate the behavior candidate set based on the second encoder to obtain a behavior vector set;

[0192] The data set X is calculated based on the first encoder i Obtain a first vector set;

[0193] The vectors corresponding to the first vector set in the behavior vector set are removed to obtain a target vector set.

[0194] When the computer program is executed by a processor, the following steps are also implemented:

[0195] A preset number of vectors are sampled from the target vector set based on a preset formula, and the vectors are merged and substituted into the strategy model formula for calculation.

[0196] When the computer program is executed by a processor, the following steps are also implemented:

[0197] The dialogue sample data is marked based on the actual completion of the dialogue task to obtain a first data set;

[0198] Counting the number of conversation rounds of each conversation sample, and obtaining a second data set based on the number of conversation rounds;

[0199] Integrate the first data set and the second data set based on a preset rule to obtain a target training data set;

[0200] Calculate a sample loss function based on the target training data set;

[0201] The first encoder and the second encoder are trained until the loss function is within a preset range to obtain a target encoder model.

[0202] When the computer program is executed by a processor, the following steps are also implemented:

[0203] Count the number of dialogue turns t for each dialogue sample i +1;

[0204] Sampling acquisition (t i +1) / 2 to t i +1 integer P i ;

[0205] The conversation sample data sequence is truncated according to the integer Pi to obtain a second data set.

[0206] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0207] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0208] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A vector retrieval method, characterized in that: The method comprises: The training data is constructed based on the collected target dialogue data, and the training data at least includes the expression data set X of each of the dialogue parties. i ,y i ; The training data is trained by supervised learning to obtain X i The first encoder model of the text turn quantity is y i a second encoder model for a text steering amount, wherein the first encoder model and the second encoder model are different encoder models; Based on the reward model and the optimization strategy model, the first encoder model and the second encoder model are updated to obtain a target encoder model; Vector retrieval is performed based on the target encoder model.

2. The vector retrieval method according to claim 1, characterized in that: The updating of the first encoder model and the second encoder model based on the reward model and the optimization strategy model to obtain the target encoder model includes: Setting a strategy model formula based on the training data, the first encoder model, and the second encoder model; Based on the actual completion of the dialogue task, the first encoder and the second encoder are trained until the loss function is within a preset range to obtain a target encoder model.

3. The vector retrieval method according to claim 2, characterized in that: The strategy model formula based on the training data, the first encoder model and the second encoder model includes: Defining the Strategy Model Formula in, θ is the parameter of the policy model π, S t , α t are the state and action at time t respectively, and sim represents the similarity calculation method between vectors; Calculate a target vector set based on the training data and the first encoder and the second encoder; Sampling is performed based on the target vector set and calculation is performed based on the strategy model formula.

4. The vector retrieval method according to claim 3, characterized in that: The target vector set calculated based on the training data and the first encoder and the second encoder includes: Using the conversation data of the answering party in the target conversation data as a behavior candidate set; Calculate the behavior candidate set based on the second encoder to obtain a behavior vector set; The data set X is calculated based on the first encoder i Obtain a first vector set; The vectors corresponding to the first vector set in the behavior vector set are removed to obtain a target vector set.

5. The vector retrieval method according to claim 4, characterized in that: The sampling based on the target vector set and the calculation based on the strategy model formula includes: A preset number of vectors are sampled from the target vector set based on a preset formula, and the vectors are merged and substituted into the strategy model formula for calculation.

6. The vector retrieval method according to claim 5, characterized in that: The training of the first encoder and the second encoder based on the actual dialogue task completion until the loss function is within a preset range to obtain a target encoder model includes: The dialogue sample data is marked based on the actual completion of the dialogue task to obtain a first data set; Counting the number of conversation rounds of each conversation sample, and obtaining a second data set based on the number of conversation rounds; Integrate the first data set and the second data set based on a preset rule to obtain a target training data set; Calculate a sample loss function based on the target training data set; The first encoder and the second encoder are trained until the loss function is within a preset range to obtain a target encoder model.

7. The vector retrieval method according to claim 6, characterized in that: The counting of the number of dialogue turns of each dialogue sample and obtaining a second data set based on the number of dialogue turns sampling comprises: Count the number of dialogue turns t for each dialogue sample i +1; Sampling acquisition (t i +1) / 2 to t i +1 integer P i ; The conversation sample data sequence is truncated according to the integer Pi to obtain a second data set.

8. A vector search device, characterized in that: The device comprises: A construction module, used to construct training data based on the collected target dialogue data, wherein the training data at least includes the expression data sets Xi, yi of the two dialogue parties; A first training module is used to train the training data by supervised learning to obtain a first encoder model of the Xi text steering amount and a second encoder model of the Yi text steering amount, wherein the first encoder model and the second encoder model are different encoder models; A second training module, used for updating the first encoder model and the second encoder model based on the reward model and the optimization strategy model to obtain a target encoder model; An execution retrieval module is used to execute vector retrieval based on the target encoder model.

9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the vector search method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the vector search method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Vector retrieval method and device, computer equipment, readable storage medium and program product

    CN121542272A

  • Vector retrieval method, device, computer equipment, readable storage medium and program product

    CN121542272B