Sentence generation model updating method and device, computer device, and storage medium
By using user-selected candidate statements as positive samples and unselected statements as negative samples in the intelligent question-answering system, and constructing a contrastive loss function to train the model, the problem of inaccurate generalization results generated by the model is solved, and higher-precision statement generation is achieved.
Patent Information
- Application Number
- CN202111388755.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-22
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2041-11-22
AI Technical Summary
In traditional intelligent question answering technology, the correlation between positive and negative samples in the parallel datasets used to train the model is poor, resulting in inaccurate generalization results generated by the model.
By acquiring the query statement triggered by the object identifier, multiple candidate statements associated with the query statement are generated. The selected candidate statements are used as positive samples, and the unselected ones are used as negative samples. Feature extraction is performed, and a contrastive loss function between positive and negative samples is constructed. The statement generation model is then updated and trained using the contrastive loss function until the stopping condition is met.
It improves the accuracy of the statement generation model, enabling it to effectively generate more gradient-like similar questions and improve the accuracy of the generalization results of the model's generated query questions.
Smart Images

Figure CN114330704B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for updating a statement generation model. Background Technology
[0002] With the development of computer technology, intelligent question-answering technology has emerged. This technology can automatically respond to user queries and recommend other related queries for the user's reference. For example, an intelligent question-answering system might answer a user's question and provide several similar questions, allowing the user to choose whether to explore further.
[0003] Traditional intelligent question answering technology typically trains a generalization model using pre-labeled parallel datasets to generate multiple generalized results corresponding to the query request. However, the correlation between positive and negative samples in the parallel datasets used to train the model is often poor, leading to inaccurate generalization results generated by the model. Summary of the Invention
[0004] Therefore, it is necessary to provide a statement generation model update method, apparatus, computer equipment, storage medium, and computer program product that can improve the accuracy of model generalization results, addressing the aforementioned technical problems.
[0005] A method for updating a statement generation model, the method comprising:
[0006] Obtain the query statement triggered by the object identifier, and generate multiple candidate statements associated with the query statement through the statement generation model;
[0007] Candidate statements selected by the object identifier are taken as positive samples, and unselected candidate statements are taken as negative samples.
[0008] Feature extraction is performed on the positive samples and the negative samples respectively to obtain the semantic representations corresponding to the positive samples and the semantic representations corresponding to the negative samples;
[0009] Based on the semantic representations of the positive samples and the negative samples, a contrastive loss function is constructed between the positive samples and the negative samples;
[0010] The sentence generation model is updated and trained using the contrastive loss function until a stopping condition is met, resulting in an updated sentence generation model.
[0011] A statement generation model update apparatus, the apparatus comprising:
[0012] The generation module is used to obtain the query statement triggered by the object identifier and generate multiple candidate statements associated with the query statement through the statement generation model;
[0013] The selection module is used to treat candidate statements selected by the object identifier as positive samples and unselected candidate statements as negative samples.
[0014] The extraction module is used to extract features from the positive samples and the negative samples respectively to obtain the semantic representations corresponding to the positive samples and the semantic representations corresponding to the negative samples.
[0015] A construction module is used to construct a contrastive loss function between the positive samples and the negative samples based on the semantic representations of the positive samples and the semantic representations of the negative samples;
[0016] The training module is used to update and train the sentence generation model using the contrastive loss function until a stopping condition is met, thus obtaining the updated sentence generation model.
[0017] In one embodiment, the generation module is further configured to, in response to an add operation triggered by an object identifier in the question-and-answer interface, obtain and display the query statement added by the object identifier; and, in response to an edit operation on the query statement triggered by the object identifier, call a statement generation model to generate multiple candidate statements associated with the query statement.
[0018] In one embodiment, the selection module is further configured to, in response to an editing operation of the query statement triggered by the object identifier, enter the editing interface of the query statement; display a viewing control of candidate statements associated with the query statement in the editing interface; display multiple candidate statements associated with the query statement in response to a triggering operation of the viewing control; and, in response to a selection operation of the multiple candidate statements, use the candidate statements selected by the selection operation as positive samples and the candidate statements not selected by the selection operation as negative samples.
[0019] In one embodiment, the construction module is further configured to traverse each sample in the sample set, the sample set including positive samples and negative samples; in each traversal, determine a first similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of each of the positive samples, and determine a second similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of the remaining samples in the sample set; and construct a contrastive loss function between the positive samples and the negative samples based on each of the first similarity relationships and each of the second similarity relationships.
[0020] In one embodiment, the construction module is further configured to determine the loss value corresponding to each sample in each traversal based on each of the first similarity relations and each of the second similarity relations corresponding to each sample in each traversal; and to determine the contrast loss function between the positive sample and the negative sample based on the loss value corresponding to each sample in each traversal.
[0021] In one embodiment, the apparatus further includes a difference determination module; the difference determination module is configured to generate a predicted statement associated with the target sample based on the semantic representation of the target sample using the statement generation model, wherein the target sample is a positive sample or a negative sample; construct a difference loss function based on the predicted statement and the labeled associated statement corresponding to the target sample; and construct a target loss function based on the contrast loss function and the difference loss function.
[0022] The training module is also used to update and train the sentence generation model using the target loss function until the stopping condition is met, thus obtaining the updated sentence generation model.
[0023] In one embodiment, the apparatus further includes an application module; the application module is configured to acquire a target query statement, generate a response statement corresponding to the target query statement, and generate an associated statement related to the target query statement based on the target query statement and the response statement through the updated statement generation model.
[0024] In one embodiment, the application module is further configured to perform feature encoding on the target query statement and the response statement respectively through the updated statement generation model to obtain the semantic representation of the target query statement and the semantic representation of the response statement; and generate an associated statement related to the target query statement based on the semantic representation of the target query statement and the semantic representation of the response statement.
[0025] In one embodiment, the updated statement generation model includes an encoder and a decoder; the application module is further configured to: segment the target query statement and the response statement using the encoder to obtain a first word sequence corresponding to the target query statement and a second word sequence corresponding to the response statement; encode the first word sequence and the second word sequence using the encoder to obtain a semantic representation of the target query statement and a semantic representation of the response statement; use the semantic representation output by the encoder as the input to the decoder; determine the target word output at the current time by using the decoded features obtained by the decoder decoding the input semantic representation at the current time and the target words output at each time point before the current time; and generate associated statements related to the target query statement based on the target words output at each time point.
[0026] In one embodiment, the updated statement generation model is applied to a knowledge question and answer base; the device further includes an application module; the application module is used to obtain a knowledge point query request for a target knowledge point, and search for knowledge point information corresponding to the knowledge point query request from the knowledge question and answer base; and call the updated statement generation model to generate multiple associated knowledge point requests based on the knowledge point query request and the knowledge point information.
[0027] In one embodiment, the updated statement generation model is applied to a logistics question-and-answer database; the device further includes an application module; the application module is used to obtain a logistics query request for a physical item, and search for logistics information corresponding to the logistics query request from the logistics question-and-answer database; call the updated statement generation model to generate multiple associated logistics requests based on the logistics query request and the logistics information; and select the associated logistics request that meets the recommendation criteria from the multiple associated logistics requests and display it on the query interface where the logistics query request is located.
[0028] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0029] Obtain the query statement triggered by the object identifier, and generate multiple candidate statements associated with the query statement through the statement generation model;
[0030] Candidate statements selected by the object identifier are taken as positive samples, and unselected candidate statements are taken as negative samples.
[0031] Feature extraction is performed on the positive samples and the negative samples respectively to obtain the semantic representations corresponding to the positive samples and the semantic representations corresponding to the negative samples;
[0032] Based on the semantic representations of the positive samples and the negative samples, a contrastive loss function is constructed between the positive samples and the negative samples;
[0033] The sentence generation model is updated and trained using the contrastive loss function until a stopping condition is met, resulting in an updated sentence generation model.
[0034] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0035] Obtain the query statement triggered by the object identifier, and generate multiple candidate statements associated with the query statement through the statement generation model;
[0036] Candidate statements selected by the object identifier are taken as positive samples, and unselected candidate statements are taken as negative samples.
[0037] Feature extraction is performed on the positive samples and the negative samples respectively to obtain the semantic representations corresponding to the positive samples and the semantic representations corresponding to the negative samples;
[0038] Based on the semantic representations of the positive samples and the negative samples, a contrastive loss function is constructed between the positive samples and the negative samples;
[0039] The sentence generation model is updated and trained using the contrastive loss function until a stopping condition is met, resulting in an updated sentence generation model.
[0040] A computer program product, comprising a computer program that, when executed by a processor, performs the following steps:
[0041] Obtain the query statement triggered by the object identifier, and generate multiple candidate statements associated with the query statement through the statement generation model;
[0042] Candidate statements selected by the object identifier are taken as positive samples, and unselected candidate statements are taken as negative samples.
[0043] Feature extraction is performed on the positive samples and the negative samples respectively to obtain the semantic representations corresponding to the positive samples and the semantic representations corresponding to the negative samples;
[0044] Based on the semantic representations of the positive samples and the negative samples, a contrastive loss function is constructed between the positive samples and the negative samples;
[0045] The sentence generation model is updated and trained using the contrastive loss function until a stopping condition is met, resulting in an updated sentence generation model.
[0046] The aforementioned statement generation model update method, apparatus, computer device, storage medium, and computer program product, by acquiring a query statement triggered by an object identifier, generate multiple candidate statements associated with the query statement through a statement generation model, thus providing the user with multiple statements similar to the query statement. By using the candidate statements selected by the object identifier as positive samples and the unselected candidate statements as negative samples, the system can identify similar questions selected by the user as positive samples and unselected similar questions as negative samples from the provided similar questions, ensuring a certain correlation between the collected positive and negative samples. Feature extraction is performed on both positive and negative samples to obtain semantic representations for the positive and negative samples respectively. Based on these semantic representations, a contrastive loss function is constructed between the positive and negative samples. The sentence generation model is then updated and trained using this contrastive loss function to narrow the distance between positive samples and widen the distance between negative samples until a stopping condition is met, resulting in an updated sentence generation model. By updating and training the sentence generation model using related positive and negative samples, the accuracy of the sentence generation model is improved, enabling it to effectively generate more gradient-like similar questions and enhancing the accuracy of generalizing query questions generated by the sentence generation model. Attached Figure Description
[0047] Figure 1 This is a diagram illustrating the application environment of a statement generation model update method in one embodiment.
[0048] Figure 2 This is a flowchart illustrating a statement generation model update method in one embodiment;
[0049] Figure 3 This is a schematic diagram of the question-and-answer interface in one embodiment;
[0050] Figure 4 This is a schematic diagram of the editing interface in another embodiment;
[0051] Figure 5 This is a schematic diagram of an interface displaying related statements in an editing interface, as shown in one embodiment.
[0052] Figure 6 This is a flowchart illustrating the statement generation model update method in another embodiment;
[0053] Figure 7 This is a schematic diagram illustrating the process of updating and training a sentence generation model using a target loss function in one embodiment.
[0054] Figure 8 This is a flowchart illustrating the steps of generating an associated statement related to the target query statement in one embodiment.
[0055] Figure 9This is a schematic diagram illustrating the structure of generating an associated statement related to the target query statement in one embodiment;
[0056] Figure 10 This is a structural block diagram of a statement generation model update device in one embodiment;
[0057] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0058] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0059] The operational data processing method provided in this application can be applied to, for example... Figure 1 The application environment is shown. This application relates to the field of Artificial Intelligence (AI) technology, whereby AI is the theory, method, technology, and application system for simulating, extending, and expanding human intelligence using digital computers or machines controlled by digital computers, perceiving the environment, acquiring knowledge, and using that knowledge to obtain optimal results. In other words, AI is a comprehensive technology of computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to have the functions of perception, reasoning, and decision-making. The solutions provided in the embodiments of this application relate to a sentence generation model update method for AI, which will be specifically described through the following embodiments.
[0060] The statement generation model update method provided in this application can be applied to, for example, Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated on server 104 or placed on a cloud or other network server. Both terminal 102 and server 104 can independently execute the statement generation model update method provided in this embodiment. Terminal 102 and server 104 can also work together to execute the statement generation model update method provided in this embodiment. When terminal 102 and server 104 work together to execute the statement generation model update method provided in this embodiment, terminal 102 obtains a query statement triggered by an object identifier and sends the query statement to server 104. Server 104 generates multiple candidate statements associated with the query statement using the statement generation model and returns the multiple candidate statements to terminal 102. Terminal 102 uses the candidate statements selected by the object identifier as positive samples and the unselected candidate statements as negative samples. Terminal 102 sends positive and negative samples to server 104. Server 104 extracts features from the positive and negative samples using a sentence generation model, obtaining semantic representations for the positive and negative samples respectively. Based on the semantic representations of the positive and negative samples, server 104 constructs a contrastive loss function between the two samples. Server 104 updates and trains the sentence generation model using the contrastive loss function until a stopping condition is met, resulting in an updated sentence generation model.
[0061] Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0062] In one embodiment, such as Figure 2 As shown, a method for updating a statement generation model is provided, which is applied to a computer device (specifically, the computer device can be...). Figure 1 Taking a terminal or server as an example, the following steps are included:
[0063] Step S202: Obtain the query statement triggered by the object identifier, and generate multiple candidate statements associated with the query statement through the statement generation model.
[0064] Here, the object identifier refers to the unique identifier of a user object, including but not limited to user identifier and device identifier. The user identifier can specifically be a username or user account. A user account refers to an account registered in the application. The device identifier can specifically be the unique identifier of the electronic device used by the user object.
[0065] An application consists of a parent application and child applications running on that parent application. The parent application is an application that can run independently. A child application is an application that cannot run independently and requires the parent application to function. Both parent and child applications can include, but are not limited to, instant messaging applications, SNS (Social Network Sites) applications, short video applications, long video applications, game applications, music sharing applications, shopping and sales applications, UGC (User Generated Content) applications, and various intelligent recognition applications.
[0066] A query is a statement used to search for a resource. Query statements include text, and may also include at least one of the following: emoticons, tags, links, and thumbnails. Resources can be at least one of various types of information and various types of items. Various types of information include at least one of the following, but are not limited to: applications, text, emoticons, images, audio, video, files, or links. Various types of items can include physical items and virtual items. Physical items include various physical products, specifically electronic products such as mobile phones, computers, laptops, and watches, as well as clothing and shoes; no further restrictions are imposed here.
[0067] Virtual items include, but are not limited to, insurance products, financial products, virtual gift resources, virtual scenes, virtual characters, and virtual props. Virtual scenes can specifically be game scenes on gaming devices, virtual reality simulation scenes, etc.; virtual characters can specifically be various characters in games; and virtual props can specifically be various props in games.
[0068] Candidate statements are statements generated by the statement generation model that are similar to the query statement. Specifically, they can be statements with similar content to the query statement. Association refers to a relationship or similarity between two statements in terms of content. Candidate statements associated with the query statement are those with similar content to the query statement. Candidate statements are also called generalized results of the query statement.
[0069] Specifically, users can log in to an application with question-and-answer functionality using an object identifier and send a query statement on that application. The computer device obtains the query statement triggered by the object identifier, calls the statement generation model, and inputs the query statement into the statement generation model. The statement generation model then generates multiple candidate statements related to the content of the query statement.
[0070] In one embodiment, generating multiple candidate statements associated with a query statement through a statement generation model includes: performing feature encoding on the query statement through the statement generation model to obtain a semantic representation corresponding to the query statement; and generating multiple candidate statements associated with the query statement based on the semantic representation corresponding to the query statement through the statement generation model.
[0071] In one embodiment, a statement generation model generates multiple candidate statements associated with the query statement, including:
[0072] Obtain the response statement corresponding to the query statement. Input the query statement and the corresponding response statement into the statement generation model. Based on the query statement and the corresponding response statement, the response statement generation model outputs multiple candidate statements associated with the query statement.
[0073] A response statement refers to information provided in response to a query statement. Specifically, it may include at least one of the following: text, audio, video, image, and link, but is not limited to these:
[0074] Specifically, computer equipment can encode the query statement and its corresponding response statement using a response statement generation model to obtain the semantic representation of the query statement and the semantic representation of the response statement. Based on the semantic representation of the query statement and the semantic representation of the response statement, the response statement generation model generates multiple candidate statements.
[0075] Furthermore, the computer device can perform word segmentation on the query statement and the corresponding response statement using a response statement generation model, obtaining the word sequence corresponding to the query statement and the word sequence corresponding to the response statement. The response statement generation model then performs feature encoding on the word sequences of the query statement and the response statement respectively, obtaining the semantic representation of the query statement and the semantic representation of the response statement.
[0076] In one embodiment, a statement generation model generates multiple candidate statements associated with the query statement, including:
[0077] The query generation model generates response statements corresponding to the query statements; based on the query statements and their corresponding response statements, the query generation model outputs multiple candidate statements associated with the query statements.
[0078] Step S204: Select the candidate statement selected by object identifier as a positive sample, and the unselected candidate statement as a negative sample.
[0079] Specifically, after a user submits a query, the computer device generates multiple candidate statements using a statement generation model and returns them to the terminal where the object identifier resides. The user can then select the candidate statement they wish to query further or want to learn more about from these candidate statements using the object identifier. The computer device can detect the object identifier's selection operation among the multiple candidate statements and determine the selected candidate statement. The computer device treats the candidate statement selected by the object identifier as a positive sample and the unselected candidate statements as negative samples.
[0080] In one embodiment, the computer device may identify the selected candidate statement and the query statement as positive samples, and add the positive and negative samples to the sample set.
[0081] Step S206: Perform feature extraction on positive and negative samples respectively to obtain the semantic representations corresponding to positive and negative samples.
[0082] Specifically, the computer device can perform word segmentation on positive and negative samples separately, obtaining word sequences corresponding to each positive sample and each negative sample. The computer device then extracts features from each word sequence to obtain semantic representations for each positive and negative sample.
[0083] Step S208: Based on the semantic representations of positive samples and negative samples, construct a contrastive loss function between positive and negative samples.
[0084] The contrastive loss function refers to the loss function used in contrastive learning, a type of self-supervised learning used to narrow the distance between positive samples and widen the distance between negative samples.
[0085] Specifically, the computer device calculates the contrastive loss for each sample based on the semantic representation corresponding to each positive sample and the semantic representation corresponding to each negative sample. The computer device then constructs a contrastive loss function between positive and negative samples based on the contrastive loss for each sample.
[0086] Step S210: Update and train the sentence generation model by comparing the loss function until the stopping condition is met, and obtain the updated sentence generation model.
[0087] Specifically, the computer equipment updates and trains the sentence generation model by comparing the loss function. During training, the parameters are adjusted based on the loss generated by the sentence generation model and training continues until the stopping condition is met, at which point the updated sentence generation model is obtained.
[0088] The stopping condition can be reaching the required number of iterations, or the comparison loss value being less than or equal to the loss threshold.
[0089] For example, during training, the contrastive loss value of the sentence generation model is determined based on the contrastive loss function. When the contrastive loss value is greater than the loss threshold, the parameters of the sentence generation model are adjusted and training continues until the contrastive loss value of the sentence generation model is less than or equal to the loss threshold, at which point the updated sentence generation model is obtained.
[0090] In the above-described statement generation model update method, a query statement triggered by an object identifier is obtained. The statement generation model then generates multiple candidate statements associated with the query statement, providing the user with several statements similar to the query. Candidate statements selected by the object identifier are used as positive samples, while unselected candidate statements are used as negative samples. This ensures that the user-selected similar questions are treated as positive samples, and the unselected similar questions as negative samples, creating a correlation between the collected positive and negative samples. Feature extraction is performed on both positive and negative samples to obtain semantic representations for the positive and negative samples respectively. Based on these semantic representations, a contrastive loss function is constructed between the positive and negative samples. The statement generation model is then updated and trained using this contrastive loss function to narrow the distance between positive and negative samples and widen the distance between them, until a stopping condition is met, resulting in an updated statement generation model. By updating and training the statement generation model with correlated positive and negative samples, the model achieves higher accuracy, effectively generating more gradient-like similar questions and improving the accuracy of generalizing query questions. Furthermore, the sentence generation model can automatically update its training based on the positive and negative samples selected by the user, enabling real-time updates of the sentence generation model.
[0091] In one embodiment, a query statement triggered by an object identifier is obtained, and multiple candidate statements associated with the query statement are generated through a statement generation model, including:
[0092] In response to the addition operation triggered by the object identifier in the Q&A interface, the query statement added by the object identifier is obtained and displayed; in response to the editing operation of the query statement triggered by the object identifier, the statement generation model is called to generate multiple candidate statements associated with the query statement.
[0093] The Q&A interface refers to the user interface that displays conversation messages generated by object identifiers. It allows users to edit, retrieve, and display these messages, and can display them in chronological order. This Q&A interface can also display at least one of the following: conversation identifier, conversation description information, number of users corresponding to the conversation, conversation user identifier, description information of the user corresponding to the conversation, and the meaning of emoticons.
[0094] Specifically, users enter the Q&A interface through an object identifier, where a query addition control is displayed. Users can trigger this addition control to initiate the addition of a query. This addition operation includes, but is not limited to, at least one of the following: touch operation, voice operation, operation via an input device such as a mouse, or gesture operation. For example, it can be any one of a click operation, double click operation, long press operation, left swipe operation, or right swipe operation, but is not limited to these.
[0095] In response to an add operation triggered on the Q&A interface, the computer device obtains the query statement entered by the user and displays it on the Q&A interface. The computer device displays an editing control for the query statement on the Q&A interface, which the user can trigger to edit the query statement. When the computer device detects an editing operation on the query statement, it invokes a statement generation model, inputting the query statement into the model to output multiple candidate statements associated with the query statement.
[0096] In this embodiment, in response to the addition operation triggered by the object identifier in the question and answer interface, the query statement added by the object identifier is obtained and displayed. In response to the editing operation of the query statement triggered by the object identifier, the statement generation model can be automatically invoked to generate multiple candidate statements associated with the query statement through the user's operation, so as to provide the user with multiple similar questions, making it convenient for the user to conduct further queries and understanding.
[0097] In one embodiment, selecting candidate statements by object identifier as positive samples and unselected candidate statements as negative samples includes:
[0098] In response to an editing operation on the query statement triggered by an object identifier, enter the query statement editing interface;
[0099] The editing interface displays a view control for candidate statements associated with the query statement; in response to a trigger operation on the view control, multiple candidate statements associated with the query statement are displayed; in response to a selection operation on multiple candidate statements, the candidate statement selected by the selection operation is used as a positive sample, and the candidate statements not selected by the selection operation are used as negative samples.
[0100] Editing operations can specifically include touch operations, cursor operations, button operations, or voice operations. Touch operations can include touch clicks, touch presses, or touch swipes, and can be single-point or multi-point touches. Cursor operations can involve controlling the cursor to click, press, or swipe. Button operations can be virtual buttons or physical buttons.
[0101] The selection operation can specifically be an operation to select from candidate statements, including but not limited to at least one of touch operation, voice operation, operation through an input device such as a mouse, or gesture operation.
[0102] Specifically, the computer device displays an editing control for the query statement on the question-and-answer interface. Users can trigger this editing control to enter the query statement editing interface. The editing interface displays a detailed description of the query statement, including its category and corresponding response statements. Furthermore, the editing interface displays a view control for candidate statements associated with the query statement. Users can trigger this view control, and the computer device, in response, retrieves and displays multiple candidate statements associated with the query statement. Users can select from these candidate statements. The computer device detects the user's action, treating the selected candidate statement as a positive sample and the unselected candidate statements as negative samples.
[0103] like Figure 3 The question-and-answer interface 300 shown includes a query statement addition control 302. Users can add a query statement by triggering this control 302, such as the added query statement 304 being "a simple question," and this query statement 304 will be displayed on the question-and-answer interface 300. Furthermore, an editing control 306 is provided in the display area of the query statement 304. Users can trigger this editing control 306 to automatically invoke a statement generation model to generate multiple candidate statements associated with the query statement 304 "a simple question." Additionally, triggering this editing control 306 allows users to access... Figure 4 The editing interface shown.
[0104] like Figure 4 As shown, the editing interface 400 displays detailed information about the query statement 304, including its category and corresponding response statements. Furthermore, the editing interface 400 displays a view control 402 for candidate statements associated with the query statement, such as "Similar Questions". When the user triggers the view control 402, five candidate statements 404 associated with the query statement 304 can be displayed, such as... Figure 5 As shown. Users can select from multiple candidate statements 404 displayed. The candidate statement selected by the selection operation is used as a positive sample, and the candidate statements not selected by the selection operation are used as negative samples.
[0105] In this embodiment, a view control for candidate statements associated with the query statement is displayed in the editing interface, allowing users to view the candidate statements. In response to the selection of multiple candidate statements, the user-selected candidate statement is treated as a positive sample, and the unselected candidate statement is treated as a negative sample. This ensures the correlation between the collected training data by identifying similar questions selected by the user as positive samples and unselected similar questions as negative samples from a pool of similar questions provided. Using correlated positive and negative samples to train the statement generation model effectively improves the quality and accuracy of the model's generalization results.
[0106] In one embodiment, a contrastive loss function is constructed between positive and negative samples based on the semantic representations of positive and negative samples, including:
[0107] Traverse each sample in the sample set, which includes positive and negative samples; in each traversal, determine the first similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of each positive sample, and determine the second similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of the remaining samples in the sample set; based on each first similarity relationship and each second similarity relationship, construct the contrastive loss function between positive and negative samples.
[0108] Specifically, the sample set includes positive and negative samples, and the computer device can traverse each sample in the sample set. In each traversal, the semantic representation corresponding to the currently traversed sample is determined, and based on the semantic representation of the currently traversed sample and the semantic representation of a single positive sample, the first similarity relationship between the currently traversed sample and that single positive sample is determined. Following the same processing method, the first similarity relationship between the currently traversed sample and each positive sample can be obtained.
[0109] Furthermore, the remaining samples in the sample set, excluding the currently traversed sample, are identified. Based on the semantic representation of the currently traversed sample and the semantic representation of each of the remaining samples, a second similarity relationship is determined between the currently traversed sample and each of the remaining samples. The computer device then constructs a contrastive loss function between positive and negative samples based on each first and second similarity relationship.
[0110] In this embodiment, each sample in the sample set, including positive and negative samples, is traversed. In each traversal, a first similarity relationship is determined between the semantic representation of the currently traversed sample and the semantic representation of each positive sample, and a second similarity relationship is determined between the semantic representation of the currently traversed sample and the semantic representations of the remaining samples in the sample set. This allows for the construction of a contrastive loss function based on the similarity relationship between each sample and other samples, maximizing the score of positive samples and minimizing the score of negative samples. Consequently, the semantic representations of positive and negative samples are further apart in the semantic space, i.e., bringing positive samples closer and distancing negative samples further apart. The resulting sentence generation model has higher accuracy, and the multiple generalization results of the generated query statements are more gradient-like, thus meeting user needs.
[0111] In one embodiment, a contrastive loss function between positive and negative samples is constructed based on each first similarity relation and each second similarity relation, including:
[0112] Based on the first similarity relation and the second similarity relation corresponding to the samples in each iteration, the loss value corresponding to the samples in each iteration is determined; based on the loss value corresponding to the samples in each iteration, the contrast loss function between positive and negative samples is determined.
[0113] Specifically, after determining the first similarity relationship between the currently traversed sample and each positive sample, and the second similarity relationship between the currently traversed sample and each of the remaining samples, the computer device can calculate the loss value corresponding to the currently traversed sample based on the multiple first and second similarity relationships. Following the same processing method, the loss value corresponding to each traversed sample can be obtained.
[0114] Based on the loss values corresponding to the samples in each iteration, the computer device can determine the contrastive loss function between positive and negative samples. Furthermore, the computer device can sum the loss values corresponding to the samples in each iteration, and use this summation function as the contrastive loss function.
[0115] For example, the constructed contrastive loss function L B As shown in the formula below:
[0116]
[0117] Where I is the sample set, τ is the temperature hyperparameter, P(i) is the set of positive samples, A(i) is the set of all samples in sample set I except sample i, and z i The semantic representation of sample i, z p Let z represent the semantic representation of each positive sample in the set P(i) of positive samples. aThis represents the semantic representation of each sample in the sample set I, except for sample i. Let be the loss value corresponding to sample i.
[0118] In this embodiment, based on the first similarity relationship and the second similarity relationship corresponding to the sample in each iteration, the loss value corresponding to the sample in each iteration is accurately calculated, and thus the contrast loss function between positive and negative samples is accurately constructed according to the loss value corresponding to the sample in each iteration.
[0119] like Figure 6 The diagram illustrates a flowchart of a sentence generation model update method in one embodiment. A computer device collects parallel corpus pairs, trains the sentence generation model based on these pairs, and applies the training online. The sentence generation model generates multiple candidate sentences online based on the user's query. Candidate sentences selected by the user are used as positive samples, and those not selected are used as negative samples, resulting in a multi-positive / negative sample dataset (k, [A1, A2, A3, A4…], [B1, B2, B3, B4…], where K represents the original query; [A1, A2, A3, A4…] represents the candidate sentences selected by the user (positive samples); and [B1, B2, B3, B4…] represents the candidate sentences not selected by the user (negative samples). The positive and negative samples are combined to form multi-sample pre-pairs, and a contrastive learning algorithm is used to update and train the sentence generation model, resulting in an updated sentence generation model.
[0120] In one embodiment, such as Figure 7 As shown, the method also includes:
[0121] Step S702: Based on the semantic representation of the target sample, the statement generation model generates a predicted statement associated with the target sample, which can be a positive or negative sample.
[0122] Specifically, the computer device can select a target sample from positive or negative samples in the sample set and input the target sample into the statement generation model. The statement generation model performs feature encoding processing on the target sample to obtain the corresponding semantic representation, and generates a predicted statement associated with the target sample based on the semantic representation of the target sample.
[0123] Step S704: Construct a difference loss function based on the predicted statement and the labeled associated statement corresponding to the target sample.
[0124] Specifically, the computer device acquires the labeled associated statements corresponding to the target sample. These labeled associated statements are pre-labeled statements associated with the target sample and serve as the label for the target sample. The computer device constructs a difference loss function based on the difference between the predicted statements generated by the statement generation model and the labeled associated statements.
[0125] Furthermore, the computer device constructs a difference loss function based on the difference between the semantic representation of the predicted statement and the semantic representation of the labeled associated statement.
[0126] In one embodiment, the sentence generation model determines the predicted probability distribution of the target sample based on its semantic representation. A computer device acquires the label probability distribution corresponding to the target sample and constructs a difference loss function based on the predicted probability distribution and the label probability distribution. The label probability distribution represents the true probability distribution of the target sample.
[0127] For example, the difference loss function is:
[0128] Among them, p(x) i Let q(x) be the true probability distribution of sample i. i Let be the predicted probability distribution corresponding to sample i, and let L be the difference loss function. ce Let p(x) be the true probability distribution. i ) and the predicted probability distribution q(x) i The difference between ).
[0129] Step S706: Construct the target loss function based on the contrast loss function and the difference loss function.
[0130] Specifically, the computer device sums the comparison loss function and the difference loss function to obtain the target loss function.
[0131] For example, the target loss function L is as follows:
[0132] L = L B +L ce
[0133] Among them, L B To compare loss functions, L ce This is the difference loss function.
[0134] In one embodiment, the computer device acquires the contrast weights and difference weights, determines the product of the contrast loss function and the contrast weights, and determines the product of the difference loss function and the difference weights. The two products are then summed to obtain the target loss function.
[0135] The sentence generation model is updated and trained by comparing the loss function until a stopping condition is met, resulting in an updated sentence generation model, including step S708:
[0136] Step S708: Update and train the sentence generation model using the objective loss function until the stopping condition is met, and obtain the updated sentence generation model.
[0137] Specifically, the computer equipment updates and trains the sentence generation model using a target loss function. During training, the parameters are adjusted based on the loss value generated by the sentence generation model, and training continues until a stopping condition is met, at which point the updated sentence generation model is obtained.
[0138] The stopping condition can be reaching the required number of iterations, or the target loss value being less than or equal to the loss threshold.
[0139] For example, during training, the target loss value of the sentence generation model is determined based on the target loss function. When the target loss value is greater than the loss threshold, the parameters of the sentence generation model are adjusted and training continues until the target loss value of the sentence generation model is less than or equal to the loss threshold, at which point the updated sentence generation model is obtained.
[0140] In this embodiment, a sentence generation model generates predicted sentences associated with the target sample based on the semantic representation of the target sample. The target sample can be a positive or negative sample. A difference loss function is constructed based on the predicted sentences and the corresponding labeled sentences of the target sample. This difference loss function reflects the difference between the probability distribution of the sentences predicted by the sentence generation model and the probability distribution of the actually labeled sentences. A target loss function is constructed based on the contrast loss function and the difference loss function. The sentence generation model is then updated and trained using this target loss function. This target loss function combines the difference between the predicted and actual probability distributions, as well as the contrast loss between positive and negative samples, to achieve the effect of narrowing the distance between positive samples and widening the distance between negative samples. The process stops when a stopping condition is met, resulting in higher accuracy for the sentence generation model. This allows for the generation of more gradient-like similarity questions and improves the accuracy of the generalization problem generated by the sentence generation model.
[0141] In one embodiment, the method further includes: obtaining a target query statement and generating a response statement corresponding to the target query statement; and generating an associated statement related to the target query statement based on the target query statement and the response statement using an updated statement generation model.
[0142] In this context, a related statement refers to a statement that is similar to the target query statement; specifically, it can be a statement whose content is similar to the target query statement. Related statements are also known as generalized results of the target query statement.
[0143] Specifically, the updated statement generation model is deployed on a computer device. The computer device obtains the target query statement input by the user and generates a response statement corresponding to the target query statement. The computer device then inputs the target query statement and the corresponding response statement into the updated statement generation model.
[0144] The updated statement generation model performs feature encoding on the target query statement to obtain its semantic representation. It also performs feature encoding on the response statement to obtain its semantic representation. Based on the semantic representations of the target query statement and the response statement, the updated model generates multiple related statements associated with the target query statement.
[0145] In one embodiment, the computer device inputs a target query statement into an updated statement generation model, and generates a response statement corresponding to the target query statement based on the input to the updated statement generation model.
[0146] In one embodiment, the method further includes: obtaining a target query statement and generating an associated statement based on the target query statement using an updated statement generation model.
[0147] Specifically, the computer device acquires the target query statement input by the user and inputs it into the updated statement generation model. The updated statement generation model encodes the target query statement to obtain the corresponding semantic representation and generates the corresponding related statements based on the semantic representation.
[0148] In this embodiment, the updated statement generation model has higher accuracy and generalization ability. The target query statement is obtained, and a corresponding response statement is generated. Based on the target query statement and the response statement, the updated statement generation model can generate multiple related statements that are more gradient-like and more accurate than the target query statement.
[0149] In one embodiment, the updated statement generation model generates associated statements based on the target query statement and the response statement, including:
[0150] The updated statement generation model is used to encode the features of the target query statement and the response statement to obtain the semantic representation of the target query statement and the semantic representation of the response statement. Based on the semantic representation of the target query statement and the semantic representation of the response statement, related statements associated with the target query statement are generated.
[0151] Specifically, the computer device inputs the target query and response statements into the updated statement generation model. The updated statement generation model performs word segmentation on the target query to obtain the word sequence corresponding to the target query; the updated statement generation model performs word segmentation on the response statement to obtain the word sequence corresponding to the response statement.
[0152] The updated statement generation model performs feature encoding on the word sequence corresponding to the target query statement to obtain its semantic representation. The updated model then performs feature encoding on the word sequence corresponding to the response statement to obtain its semantic representation. Next, based on the semantic representations of the target query statement and the response statement, the updated model generates multiple related statements associated with the target query statement.
[0153] In this embodiment, the updated statement generation model performs feature encoding on the target query statement and the response statement respectively, obtaining semantic representations of the target query statement and the response statement. This allows for the extraction of key semantic information from both the target query statement and the response statement. Based on the key semantic information of the target query statement and the response statement, related statements similar to the target query statement can be accurately generated. Furthermore, when generating the generalization result of the target query statement, the key semantic information of the response statement is also incorporated, further improving the accuracy of the generated generalization result.
[0154] In one embodiment, such as Figure 8 As shown, the updated statement generation model includes an encoder and a decoder; the updated statement generation model is used to encode the features of the target query statement and the response statement respectively to obtain the semantic representation of the target query statement and the semantic representation of the response statement, including steps S802 and S804:
[0155] Step S802: The target query statement and the response statement are segmented by the encoder to obtain the first word sequence corresponding to the target query statement and the second word sequence corresponding to the response statement.
[0156] Specifically, the updated statement generation model includes an encoder and a decoder. The computer device inputs the target query statement and the response statement into the encoder of the updated statement generation model.
[0157] The encoder performs word segmentation on the target query statement to obtain each word of the target query statement. Each word of the target query statement is converted into a corresponding word vector, and the first word sequence corresponding to the target query statement is obtained based on each word vector.
[0158] The encoder performs word segmentation on the response statement to obtain each word of the response statement. Each word of the response statement is converted into a corresponding word vector, and the first word sequence corresponding to the response statement is obtained based on each word vector.
[0159] Understandably, the processing order of the target query and response statements is not limited; they can be processed sequentially or simultaneously.
[0160] Step S804: The first word sequence and the second word sequence are feature encoded by the encoder to obtain the semantic representation of the target query statement and the semantic representation of the response statement.
[0161] Specifically, the encoder may include multiple encoding layers. The first encoding layer encodes features of the first word sequence and the second word sequence respectively, obtaining the encoded features corresponding to the target query statement and the response statement output by the first encoding layer. From the second encoding layer onwards, the encoded features output by the previous encoding layer are used as the input to the next encoding layer for further feature encoding, until the encoded features output by the last encoding layer are obtained. The encoded features corresponding to the target query statement output by the last encoding layer are used as the semantic representation of the target query statement. The encoded features corresponding to the response statement output by the last encoding layer are used as the semantic representation of the response statement.
[0162] In one embodiment, the encoding layer in the encoder can perform feature fusion processing on the encoded features corresponding to the target query statement and the response statement respectively to obtain fused features. The fused features are then used as the output of the encoder and input into the decoder. The decoder decodes the fused features to generate an associated statement related to the target query statement.
[0163] In one embodiment, the computer device performs word segmentation on the target query statement and the response statement respectively, obtaining a first word sequence corresponding to the target query statement and a second word sequence corresponding to the response statement. The first and second word sequences are then input into an encoder. The encoder performs feature encoding on the first and second word sequences respectively, obtaining semantic representations of the target query statement and the response statement.
[0164] Based on the semantic representation of the target query and the semantic representation of the response, a related statement is generated that is associated with the target query, including steps S806 and S808:
[0165] Step S806: The semantic representation output by the encoder is used as the input of the decoder. The target word output at the current time is determined by the decoded features obtained by the decoder decoding the input semantic representation at the current time and the target words output at each time before the current time.
[0166] Specifically, the semantic representations of the target query and the response output by the encoder are used as input to the decoder. The decoder performs feature decoding on the input semantic representations to obtain the corresponding decoded features, and generates each target word based on the decoded features.
[0167] Furthermore, the decoder decodes the semantic representation of the input in sequence. Based on the decoded features obtained from decoding the semantic representation of the input at the current time and the target words output at each time before the current time, the decoder predicts the target word at the current time.
[0168] Step S808: Generate associated statements that are related to the target query statement based on the target words output at each time point.
[0169] Specifically, the decoder generates associated statements based on the target words output at each time step. Furthermore, the decoder outputs multiple target words at each time step and generates multiple associated statements based on these target words for each time step.
[0170] In one embodiment, the decoder outputs multiple target words at each time step, and generates multiple candidate related statements based on the target words corresponding to each time step. These candidate related statements are then sorted by similarity, and a specific number of highly similar related statements are selected.
[0171] In this embodiment, the target query and response statements are segmented by an encoder to obtain a first word sequence corresponding to the target query and a second word sequence corresponding to the response. The encoder then performs feature encoding on the first and second word sequences to obtain semantic representations of the target query and response statements, enabling the extraction of key semantic information from both. The semantic representation output by the encoder is used as input to the decoder. By decoding the input semantic representation at the current time and combining the decoded features obtained from decoding the input semantic representation with the target words output at previous times, the target word output at the current time is determined. This allows for accurate prediction of the target word at the current time by combining the decoded features at the current time and the previously output target words, thereby enabling the accurate generation of related statements associated with the target query based on the target words output at each time.
[0172] In this embodiment, the sentence generation model can employ a sequence-to-sequence framework based on neural networks, or it can use a Transformer model or a BER model. The sequence-to-sequence framework includes an Encoder-Decoder structure. The Encoder-Decoder structure transforms the input sequence into another sequence output. In this framework, the encoder transforms the input sequence into a vector sequence, and the decoder generates the output sequence sequentially based on the vector sequence in chronological order. The encoder and decoder can use the same type of neural network model, or they can be different types of neural network models. For example, both the encoder and decoder can be CNN (Convolutional Neural Networks) models or RNN (Recurrent Neural Networks) models. Alternatively, the encoder and decoder can use different neural network models, such as an RNN model for the encoder and a CNN model for the decoder.
[0173] The seq2seq model in this embodiment can also be used for natural language processing tasks such as parallel corpus mining and text generation. Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies various theories and methods that enable effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language, that is, the language people use in daily life, and thus it is closely related to linguistic research. Natural language processing technologies typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.
[0174] like Figure 9The diagram illustrates the generation of associated statements related to the target query statement in one embodiment. The updated statement generation model performs word segmentation on both the target query statement and the response statement, obtaining the first word sequence [c1...cn] corresponding to the target query statement and the second word sequence [a1...an] corresponding to the response statement. Feature encoding is then performed on the first word sequence [c1...cn] and the second word sequence [a1...an] to obtain the corresponding hidden semantic representation [h1...ci]. Based on the hidden semantic representation [h1...ci], the first target word q1 is generated. The semantic representation of target word q1 and the hidden semantic representation [h1...ci] are used as input for the next time step to obtain the target word q2. Next, the semantic representations and hidden semantic representations [h1...ci] of target words q1 and q2 are used as input for the next time step to obtain the target word q3, and so on, until the last target word qj is obtained. Target words q1, q2, ..., qj constitute the associated statement.
[0175] In one embodiment, the updated statement generation model is applied to a knowledge question-answering base; the method further includes:
[0176] Obtain the knowledge point query request for the target knowledge point, and search for the knowledge point information corresponding to the knowledge point query request from the knowledge question and answer database; call the updated statement generation model to generate multiple related knowledge point requests based on the knowledge point query request and the knowledge point information.
[0177] Among them, the related knowledge point request refers to a request similar to the knowledge point query request, specifically a request that is related to the content of the knowledge point query request.
[0178] Specifically, the updated statement generation model can be applied to a knowledge question-and-answer base, which is used for intelligent searching of teaching knowledge points. This knowledge question-and-answer base is deployed on computer devices.
[0179] Users can log in to the knowledge question and answer database using an object identifier, and then enter a knowledge point query request to search for a target knowledge point. The computer device receives the user's knowledge point query request, searches for the corresponding knowledge point information in the knowledge question and answer database, and returns the knowledge point information to the user.
[0180] Computer devices can invoke an updated statement generation model, inputting a knowledge point query request and knowledge point information into it. The updated statement generation model can then perform feature encoding on the knowledge point query request and the knowledge point information, respectively, to obtain semantic representations of the query request and the information. Based on these semantic representations, the updated statement generation model generates a related knowledge point request associated with the query request.
[0181] Furthermore, the updated sentence generation model can perform word segmentation on the knowledge point query request and the knowledge point information respectively, obtaining the word sequence of the knowledge point query request and the word sequence of the knowledge point information. The updated sentence generation model then performs feature encoding on the word sequence of the knowledge point query request and the word sequence of the knowledge point information respectively, obtaining the semantic representation of the knowledge point query request and the semantic representation of the knowledge point information.
[0182] In one embodiment, a computer device may invoke an updated statement generation model to generate multiple associated knowledge point requests based on the knowledge point query request.
[0183] In one embodiment, the method further includes: selecting, from multiple related knowledge point requests, related knowledge point requests that meet the push conditions and displaying them on the query interface where the knowledge point query request is located.
[0184] The push conditions can be a preset number of requests for related knowledge points with high similarity.
[0185] Specifically, the updated statement generation model filters out the related knowledge point requests that meet the push conditions from the multiple generated related knowledge point requests, and displays the filtered related knowledge point requests on the query interface where the knowledge point query request is located.
[0186] Furthermore, the updated statement generation model can sort the generated related knowledge point requests according to their similarity to the knowledge point query request, and select a preset number of highly similar related knowledge point requests from the sorted related knowledge point requests to display on the query interface where the knowledge point query request is located, for the user to select.
[0187] In this embodiment, the updated sentence generation model is applied to a knowledge question-and-answer base, enabling its application in educational scenarios. This allows learners to quickly find relevant information about the knowledge points they need through the knowledge question-and-answer base. Furthermore, the updated sentence generation model generates multiple related knowledge point requests based on the knowledge point query request and the corresponding knowledge point information. This provides learners with more information related to the queried knowledge point, facilitating further understanding of the knowledge point. It also enables personalized recommendations of knowledge points based on the knowledge point requests.
[0188] In one embodiment, the updated statement generation model is applied to a logistics question-and-answer database; the method further includes:
[0189] Obtain the logistics query request for the physical item and search for the logistics information corresponding to the logistics query request from the logistics question and answer database; call the updated statement generation model to generate multiple associated logistics requests based on the logistics query request and logistics information.
[0190] Among them, a related logistics request refers to a request similar to a logistics query request, specifically a request that is related to the content of a logistics query request. For example, a query request for express delivery logistics.
[0191] Specifically, the updated statement generation model can be applied to a logistics question-and-answer database, which is used for intelligent retrieval of logistics information. This logistics question-and-answer database is deployed on computer equipment.
[0192] Users can log in to the logistics Q&A database using an object identifier and enter a logistics query request for a physical item. The computer device receives the user's query request, retrieves the corresponding logistics information from the logistics Q&A database, and returns the logistics information to the user.
[0193] The computer device can invoke the updated statement generation model, inputting the logistics query request and logistics information into it. The updated statement generation model can then perform feature encoding on the logistics query request and logistics information respectively, obtaining semantic representations of the logistics query request and the logistics information. Based on these semantic representations, the updated statement generation model generates a related logistics request associated with the logistics query request.
[0194] Furthermore, the updated sentence generation model can perform word segmentation on the logistics query request and logistics information respectively, obtaining word sequences for the logistics query request and logistics information. The updated sentence generation model then performs feature encoding on the word sequences for the logistics query request and logistics information respectively, obtaining semantic representations for the logistics query request and logistics information.
[0195] In one embodiment, a computer device may invoke an updated statement generation model to generate multiple associated logistics requests based on the logistics query request.
[0196] In one embodiment, the method further includes: selecting, from multiple related logistics requests, related logistics requests that meet the recommendation criteria and displaying them on the query interface where the logistics query request is located.
[0197] Specifically, the updated statement generation model filters out the related logistics requests that meet the recommendation criteria from the multiple generated related logistics requests, and displays the filtered related logistics requests on the query interface where the logistics query request is located.
[0198] In this embodiment, the updated statement generation model is applied to a logistics question-and-answer database. This allows the updated model to be used in logistics and transportation scenarios, enabling users to automatically and quickly find the logistics-related information they need through the database. Furthermore, based on the logistics query request and corresponding logistics information, the updated statement generation model generates multiple related logistics requests, providing users with more logistics information related to the queried physical item, facilitating a deeper understanding of the item's logistics details.
[0199] In one embodiment, a statement generation model update method is provided, applied to a computer device, comprising:
[0200] Get the query statement triggered by the object identifier, generate multiple candidate statements associated with the query statement through the statement generation model; take the candidate statement selected by the object identifier as the positive sample, and take the unselected candidate statement as the negative sample, and add the positive sample and the negative sample to the sample set.
[0201] Feature extraction is performed on positive and negative samples respectively to obtain the semantic representations of positive and negative samples.
[0202] Iterate through each sample in the sample set. In each iteration, determine the first similarity relationship between the semantic representation of the currently iterated sample and the semantic representation of each positive sample, and determine the second similarity relationship between the semantic representation of the currently iterated sample and the semantic representation of the remaining samples in the sample set.
[0203] Based on the first similarity relation and the second similarity relation corresponding to the samples in each iteration, the loss value corresponding to the samples in each iteration is determined; based on the loss value corresponding to the samples in each iteration, the contrast loss function between positive and negative samples is determined.
[0204] The sentence generation model generates predicted sentences associated with the target sample based on the semantic representation of the target sample, which can be a positive or negative sample. A difference loss function is constructed based on the predicted sentences and the labeled associated sentences corresponding to the target sample.
[0205] Based on the contrast loss function and the difference loss function, a target loss function is constructed.
[0206] The sentence generation model is updated and trained using the objective loss function until a stopping condition is met, resulting in an updated sentence generation model. The updated sentence generation model includes an encoder and a decoder.
[0207] Obtain the target query statement and generate the corresponding response statement;
[0208] The target query and its corresponding response are input into the updated statement generation model. The encoder performs word segmentation on the target query and response respectively to obtain the first word sequence corresponding to the target query and the second word sequence corresponding to the response.
[0209] By encoding the features of the first word sequence and the second word sequence respectively using an encoder, the semantic representations of the target query statement and the response statement are obtained.
[0210] The semantic representation output by the encoder is used as the input to the decoder. The target word to be output at the current time is determined by the decoded features obtained by the decoder decoding the input semantic representation at the current time and the target words output at each time before the current time.
[0211] Generate associated statements based on the target words output at each time point and the target query statement.
[0212] In this embodiment, by acquiring the query statement triggered by the object identifier, a statement generation model generates multiple candidate statements associated with the query statement, providing the user with multiple statements similar to the query statement. The candidate statements selected by the object identifier are used as positive samples, and the unselected candidate statements are used as negative samples. This allows the system to identify similar questions selected by the user as positive samples and unselected similar questions as negative samples from the provided similar questions, ensuring a certain correlation between the collected positive and negative samples.
[0213] By traversing each sample in the sample set, in each traversal, the first similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of each positive sample is determined, and the second similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of the remaining samples in the sample set is determined. Thus, based on the similarity relationship between each sample and other samples, a contrastive loss function can be constructed to maximize the score of positive samples and minimize the score of negative samples, thereby making the semantic representations of positive and negative samples farther apart in the semantic space.
[0214] Based on the semantic representation of the target sample, a sentence generation model generates predicted sentences associated with the target sample. A difference loss function is constructed based on the predicted sentences and the corresponding labeled sentences of the target sample. This difference loss function reflects the difference between the probability distribution of the sentences predicted by the sentence generation model and the probability distribution of the actually labeled sentences. A target loss function is constructed based on the contrastive loss function and the difference loss function. The sentence generation model is then updated and trained using this target loss function. This target loss function combines the difference between the predicted and actual probability distributions, as well as the contrastive loss between positive and negative samples, to narrow the gap between positive samples and widen the gap between negative samples. The process stops when a stopping condition is met, resulting in higher accuracy for the sentence generation model. It effectively generates multiple generalized results with greater gradient, improving the accuracy of the sentence generation model in generalizing query problems.
[0215] The updated statement generation model boasts higher accuracy and generalization ability. It acquires the target query statement, generates corresponding response statements, and uses the updated model to encode the features of both the target query and response statements, obtaining semantic representations of both. This allows for the extraction of key semantic information from both the target and response statements. Based on this key semantic information, it can generate multiple more related statements with greater gradation similarity to the target query statement, and these generated related statements are more accurate.
[0216] It should be understood that, although Figure 2 , Figures 6-9 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 2 , Figures 6-9At least some of the steps in the process may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but may be executed at different times. The execution order of these steps or stages is not necessarily sequential, but may be executed in turn or alternately with other steps or at least some of the steps or stages in other steps.
[0217] In one embodiment, such as Figure 10 As shown, a sentence generation model update device is provided. This device can be a software module, a hardware module, or a combination of both integrated into a computer device. Specifically, the device includes: a generation module 1002, a selection module 1004, an extraction module 1006, a construction module 1008, and a training module 1010, wherein:
[0218] The generation module 1002 is used to obtain the query statement triggered by the object identifier and generate multiple candidate statements associated with the query statement through the statement generation model.
[0219] The selected module 1004 is used to treat the candidate statements selected by object identifier as positive samples and the unselected candidate statements as negative samples.
[0220] The extraction module 1006 is used to extract features from positive and negative samples respectively, so as to obtain the semantic representations of positive samples and negative samples.
[0221] Module 1008 is used to construct a contrastive loss function between positive and negative samples based on the semantic representations of positive and negative samples.
[0222] Training module 1010 is used to update and train the sentence generation model by comparing the loss function until the stopping condition is met, thus obtaining the updated sentence generation model.
[0223] In this embodiment, a query statement triggered by an object identifier is obtained. A statement generation model generates multiple candidate statements associated with the query statement, providing the user with several statements similar to the query. Candidate statements selected by the object identifier are used as positive samples, and unselected candidate statements are used as negative samples. This allows the user-selected similar questions to be used as positive samples and the unselected similar questions as negative samples, ensuring a certain correlation between the collected positive and negative samples. Feature extraction is performed on both positive and negative samples to obtain semantic representations for the positive and negative samples respectively. Based on these semantic representations, a contrastive loss function is constructed between the positive and negative samples. The statement generation model is then updated and trained using this contrastive loss function to narrow the distance between positive and negative samples and widen the distance between them, until a stopping condition is met, resulting in an updated statement generation model. By updating and training the statement generation model with associated positive and negative samples, the accuracy of the statement generation model is improved, enabling it to effectively generate more gradient-like similar questions and enhancing the accuracy of the generalization problem of the query generated by the statement generation model.
[0224] In one embodiment, the generation module 1002 is further configured to, in response to an add operation triggered by an object identifier in the question-and-answer interface, obtain and display the query statement added by the object identifier; and, in response to an edit operation on the query statement triggered by the object identifier, call the statement generation model to generate multiple candidate statements associated with the query statement.
[0225] In this embodiment, in response to the addition operation triggered by the object identifier in the question and answer interface, the query statement added by the object identifier is obtained and displayed. In response to the editing operation of the query statement triggered by the object identifier, the statement generation model can be automatically invoked to generate multiple candidate statements associated with the query statement through the user's operation, so as to provide the user with multiple similar questions, making it convenient for the user to conduct further queries and understanding.
[0226] In one embodiment, the selected module 1004 is further configured to enter the query statement editing interface in response to an editing operation of the query statement triggered by the object identifier; display a viewing control of candidate statements associated with the query statement in the editing interface; display multiple candidate statements associated with the query statement in response to a triggering operation of the viewing control; and, in response to a selection operation of multiple candidate statements, use the candidate statements selected by the selection operation as positive samples and the candidate statements not selected by the selection operation as negative samples.
[0227] In this embodiment, a view control for candidate statements associated with the query statement is displayed in the editing interface, allowing users to view the candidate statements. In response to the selection of multiple candidate statements, the user-selected candidate statement is treated as a positive sample, and the unselected candidate statement is treated as a negative sample. This ensures the correlation between the collected training data by identifying similar questions selected by the user as positive samples and unselected similar questions as negative samples from a pool of similar questions provided. Using correlated positive and negative samples to train the statement generation model effectively improves the quality and accuracy of the model's generalization results.
[0228] In one embodiment, the construction module 1008 is further configured to traverse each sample in the sample set, which includes positive samples and negative samples; in each traversal, determine a first similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of each positive sample, and determine a second similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of the remaining samples in the sample set; and construct a contrastive loss function between positive samples and negative samples based on each first similarity relationship and each second similarity relationship.
[0229] In this embodiment, each sample in the sample set, including positive and negative samples, is traversed. In each traversal, a first similarity relationship is determined between the semantic representation of the currently traversed sample and the semantic representation of each positive sample, and a second similarity relationship is determined between the semantic representation of the currently traversed sample and the semantic representations of the remaining samples in the sample set. This allows for the construction of a contrastive loss function based on the similarity relationship between each sample and other samples, maximizing the score of positive samples and minimizing the score of negative samples. Consequently, the semantic representations of positive and negative samples are further apart in the semantic space, i.e., bringing positive samples closer and distancing negative samples further apart. The resulting sentence generation model has higher accuracy, and the multiple generalization results of the generated query statements are more gradient-like, thus meeting user needs.
[0230] In one embodiment, the construction module 1008 is further configured to determine the loss value corresponding to each sample in each iteration based on each first similarity relation and each second similarity relation corresponding to the sample in each iteration; and to determine the contrast loss function between positive and negative samples based on the loss value corresponding to each sample in each iteration.
[0231] In this embodiment, based on the first similarity relationship and the second similarity relationship corresponding to the sample in each iteration, the loss value corresponding to the sample in each iteration is accurately calculated, and thus the contrast loss function between positive and negative samples is accurately constructed according to the loss value corresponding to the sample in each iteration.
[0232] In one embodiment, the apparatus further includes a difference determination module; the difference determination module is used to generate a predicted statement associated with the target sample based on the semantic representation of the target sample through a statement generation model, wherein the target sample is a positive sample or a negative sample; construct a difference loss function based on the predicted statement and the labeled associated statement corresponding to the target sample; and construct a target loss function based on the contrast loss function and the difference loss function.
[0233] Training module 1010 is also used to update and train the sentence generation model using the target loss function until the stopping condition is met, thus obtaining the updated sentence generation model.
[0234] In this embodiment, a sentence generation model generates predicted sentences associated with the target sample based on the semantic representation of the target sample. The target sample can be a positive or negative sample. A difference loss function is constructed based on the predicted sentences and the corresponding labeled sentences of the target sample. This difference loss function reflects the difference between the probability distribution of the sentences predicted by the sentence generation model and the probability distribution of the actually labeled sentences. A target loss function is constructed based on the contrast loss function and the difference loss function. The sentence generation model is then updated and trained using this target loss function. This target loss function combines the difference between the predicted and actual probability distributions, as well as the contrast loss between positive and negative samples, to achieve the effect of narrowing the distance between positive samples and widening the distance between negative samples. The process stops when a stopping condition is met, resulting in higher accuracy for the sentence generation model. This allows for the generation of more gradient-like similarity questions and improves the accuracy of the generalization problem generated by the sentence generation model.
[0235] In one embodiment, the device further includes an application module; the application module is configured to obtain a target query statement, generate a response statement corresponding to the target query statement, and generate an associated statement related to the target query statement based on the target query statement and the response statement through an updated statement generation model.
[0236] In this embodiment, the updated statement generation model has higher accuracy and generalization ability. The target query statement is obtained, and a corresponding response statement is generated. Based on the target query statement and the response statement, the updated statement generation model can generate multiple related statements that are more gradient-like and more accurate than the target query statement.
[0237] In one embodiment, the application module is further configured to perform feature encoding on the target query statement and the response statement respectively through the updated statement generation model to obtain the semantic representation of the target query statement and the semantic representation of the response statement; and generate an associated statement related to the target query statement based on the semantic representation of the target query statement and the semantic representation of the response statement.
[0238] In this embodiment, the updated statement generation model performs feature encoding on the target query statement and the response statement respectively, obtaining semantic representations of the target query statement and the response statement. This allows for the extraction of key semantic information from both the target query statement and the response statement. Based on the key semantic information of the target query statement and the response statement, related statements similar to the target query statement can be accurately generated. Furthermore, when generating the generalization result of the target query statement, the key semantic information of the response statement is also incorporated, further improving the accuracy of the generated generalization result.
[0239] In one embodiment, the updated statement generation model includes an encoder and a decoder; the application module is further configured to perform word segmentation on the target query statement and the response statement respectively through the encoder to obtain a first word sequence corresponding to the target query statement and a second word sequence corresponding to the response statement; perform feature encoding on the first word sequence and the second word sequence respectively through the encoder to obtain the semantic representation of the target query statement and the semantic representation of the response statement; use the semantic representation output by the encoder as the input of the decoder, and determine the target word output at the current time by using the decoded features obtained by the decoder decoding the input semantic representation at the current time and the target words output at each time before the current time; and generate associated statements related to the target query statement based on the target words output at each time.
[0240] In this embodiment, the target query and response statements are segmented by an encoder to obtain a first word sequence corresponding to the target query and a second word sequence corresponding to the response. The encoder then performs feature encoding on the first and second word sequences to obtain semantic representations of the target query and response statements, enabling the extraction of key semantic information from both. The semantic representation output by the encoder is used as input to the decoder. By decoding the input semantic representation at the current time and combining the decoded features obtained from decoding the input semantic representation with the target words output at previous times, the target word output at the current time is determined. This allows for accurate prediction of the target word at the current time by combining the decoded features at the current time and the previously output target words, thereby enabling the accurate generation of related statements associated with the target query based on the target words output at each time.
[0241] In one embodiment, the updated statement generation model is applied to a knowledge question and answer base; the device further includes an application module; the application module is used to obtain a knowledge point query request for a target knowledge point, and search for knowledge point information corresponding to the knowledge point query request from the knowledge question and answer base; and call the updated statement generation model to generate multiple associated knowledge point requests based on the knowledge point query request and the knowledge point information.
[0242] In this embodiment, the updated sentence generation model is applied to a knowledge question-and-answer base, enabling its application in educational scenarios. This allows learners to quickly find relevant information about the knowledge points they need through the knowledge question-and-answer base. Furthermore, the updated sentence generation model generates multiple related knowledge point requests based on the knowledge point query request and the corresponding knowledge point information. This provides learners with more information related to the queried knowledge point, facilitating further understanding of the knowledge point. It also enables personalized recommendations of knowledge points based on the knowledge point requests.
[0243] In one embodiment, the updated statement generation model is applied to a logistics question-and-answer database; the device also includes an application module; the application module is used to obtain a logistics query request for a physical item and search for logistics information corresponding to the logistics query request from the logistics question-and-answer database; call the updated statement generation model to generate multiple associated logistics requests based on the logistics query request and the logistics information; and select the associated logistics request that meets the recommendation criteria from the multiple associated logistics requests and display it on the query interface where the logistics query request is located.
[0244] In this embodiment, the updated statement generation model is applied to a logistics question-and-answer database. This allows the updated model to be used in logistics and transportation scenarios, enabling users to automatically and quickly find the logistics-related information they need through the database. Furthermore, based on the logistics query request and corresponding logistics information, the updated statement generation model generates multiple related logistics requests, providing users with more logistics information related to the queried physical item, facilitating a deeper understanding of the item's logistics details.
[0245] Specific limitations regarding the statement generation model update device can be found in the limitations of the statement generation model update method described above, and will not be repeated here. Each module in the aforementioned statement generation model update device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0246] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 11As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a statement generation model update method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0247] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0248] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0249] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0250] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.
[0251] It should be noted that the user information (including but not limited to user device information, user personal information, such as object identifiers) and data (including but not limited to data used for analysis, stored data, and displayed data) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. Furthermore, users can refuse or easily refuse push notifications such as candidate statements and related statements.
[0252] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0253] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0254] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for updating a statement generation model, characterized in that, The method includes: Parallel corpus pairs are collected, and the sentence generation model is trained based on the parallel corpus pairs. After training, the sentence generation model is used to generate multiple candidate sentences with similar content based on the query sentences of object input online. The query statement added by the object identifier is displayed in the question and answer interface; In response to an editing operation on the query statement triggered by the object identifier, the system enters the editing interface for the query statement. The editing interface displays a view control for candidate statements associated with the query statement; In response to the triggering operation of the viewing control, the statement generation model is invoked to generate a response statement corresponding to the query statement. Based on the semantic representation of the query statement and the semantic representation of the response statement, multiple candidate statements similar to the content of the query statement are generated and displayed. In response to the selection operation of the plurality of candidate statements displayed, the candidate statements selected by the selection operation among the plurality of candidate statements are taken as positive samples, and the candidate statements not selected by the selection operation among the plurality of candidate statements are taken as negative samples, and the positive samples and the negative samples constitute a sample set. Feature extraction is performed on the positive samples and the negative samples respectively to obtain the semantic representations corresponding to the positive samples and the semantic representations corresponding to the negative samples; The sample set is traversed. In each traversal, a first similarity relationship is determined between the semantic representation of the currently traversed sample and the semantic representation of each positive sample, and a second similarity relationship is determined between the semantic representation of the currently traversed sample and the semantic representation of the remaining samples in the sample set. Based on each first similarity relationship and each second similarity relationship, a contrast loss function between the positive sample and the negative sample is constructed. The statement generation model generates a predicted statement associated with the sample based on the semantic representation of the sample in the sample set. Based on the predicted statement and the labeled associated statement corresponding to the sample, a difference loss function is constructed. Based on the contrast loss function and the difference loss function, a target loss function is constructed, and the sentence generation model is updated and trained through the target loss function until the stopping condition is met, thus obtaining the updated sentence generation model. Obtain a knowledge point query request and search for the knowledge point information corresponding to the knowledge point query request from the knowledge question and answer database; The updated statement generation model is invoked to generate multiple related knowledge point requests that are similar to the knowledge point query request, based on the semantic representation of the knowledge point query request and the semantic representation of the knowledge point information.
2. The method according to claim 1, characterized in that, The step of constructing a contrast loss function between the positive samples and the negative samples based on each of the first similarity relationships and each of the second similarity relationships includes: Based on the first similarity relation and the second similarity relation corresponding to the sample in each iteration, the loss value corresponding to the sample in each iteration is determined. Based on the loss value corresponding to each sample in each iteration, the contrast loss function between the positive sample and the negative sample is determined.
3. The method according to claim 1, characterized in that, The method further includes: Obtain the target query statement and generate a response statement corresponding to the target query statement; The updated statement generation model generates associated statements based on the target query statement and the corresponding response statement.
4. The method according to claim 3, characterized in that, The statement generation model, after the update, generates associated statements based on the target query statement and the corresponding response statement, including: The updated statement generation model is used to perform feature encoding on the target query statement and the response statement respectively to obtain the semantic representation of the target query statement and the semantic representation of the response statement. Based on the semantic representation of the target query statement and the semantic representation of the response statement, an associated statement is generated that is related to the target query statement.
5. The method according to claim 4, characterized in that, The updated statement generation model includes an encoder and a decoder; the updated statement generation model is used to perform feature encoding on the target query statement and the response statement respectively to obtain the semantic representation of the target query statement and the semantic representation of the response statement, including: The encoder performs word segmentation on the target query statement and the response statement respectively to obtain the first word sequence corresponding to the target query statement and the second word sequence corresponding to the response statement; The encoder performs feature encoding on the first word sequence and the second word sequence respectively to obtain the semantic representation of the target query statement and the semantic representation of the response statement; The step of generating an associated statement based on the semantic representation of the target query statement and the semantic representation of the response statement includes: The semantic representation output by the encoder is used as the input of the decoder. The target word output at the current time is determined by the decoded features obtained by the decoder decoding the input semantic representation at the current time and the target words output at each time before the current time. Based on the target words output at each time point, generate associated statements that are related to the target query statement.
6. The method according to any one of claims 1 to 5, characterized in that, The updated statement generation model is applied to the logistics question-and-answer database; the method further includes: Obtain a logistics query request for a physical item, and search for the logistics information corresponding to the logistics query request from the logistics question and answer database; The updated statement generation model is invoked to generate multiple associated logistics requests based on the logistics query request and the logistics information; The method further includes: From the multiple related logistics requests, the related logistics requests that meet the recommended criteria are selected and displayed on the query interface where the logistics query request is located.
7. A statement generation model updating device, characterized in that, The device includes: The pre-training module is used to collect parallel corpus pairs and train the sentence generation model based on the parallel corpus pairs. After training, the sentence generation model is used to generate multiple candidate sentences with similar content based on the query sentences of object input online. The generation module is used to display query statements added by object identifiers in the question-and-answer interface; The selected module is used to enter the query statement editing interface in response to an editing operation triggered by the object identifier; in the editing interface, a viewing control for candidate statements associated with the query statement is displayed; in response to a triggering operation of the viewing control, the statement generation model is invoked to generate a response statement corresponding to the query statement, and multiple candidate statements similar to the content of the query statement are generated and displayed based on the semantic representation corresponding to the query statement and the semantic representation corresponding to the response statement; in response to a selection operation of the displayed multiple candidate statements, the candidate statements selected by the selection operation are taken as positive samples, and the candidate statements not selected by the selection operation are taken as negative samples, and the positive samples and the negative samples constitute a sample set; The extraction module is used to extract features from the positive samples and the negative samples respectively to obtain the semantic representations corresponding to the positive samples and the semantic representations corresponding to the negative samples. The construction module is used to traverse each sample in the sample set. In each traversal, it determines a first similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of each positive sample, and determines a second similarity relationship between the semantic representation of the currently traversed sample and the semantic representation of the remaining samples in the sample set. Based on each first similarity relationship and each second similarity relationship, it constructs a contrastive loss function between the positive sample and the negative sample. The construction module is used to generate a predicted statement associated with the sample based on the semantic representation of the sample in the sample set through the statement generation model, and to construct a difference loss function based on the predicted statement and the labeled associated statement corresponding to the sample. The training module is used to construct a target loss function based on the contrast loss function and the difference loss function, and to update and train the sentence generation model through the target loss function until the stopping condition is met, thus obtaining the updated sentence generation model. The application module is used to obtain knowledge point query requests, search for knowledge point information corresponding to the knowledge point query requests from the knowledge question and answer database, and call the updated statement generation model to generate multiple related knowledge point requests with gradients that are similar to the knowledge point query requests based on the semantic representation of the knowledge point query requests and the semantic representation of the knowledge point information.
8. The apparatus according to claim 7, characterized in that, The construction module is further configured to determine the loss value corresponding to each sample in each traversal based on each of the first similarity relationships and each of the second similarity relationships corresponding to the samples in each traversal; and to determine the contrast loss function between the positive samples and the negative samples based on the loss values corresponding to each sample in each traversal.
9. The apparatus according to claim 7, characterized in that, The device further includes: The application module is used to obtain the target query statement and generate a response statement corresponding to the target query statement; based on the target query statement and the response statement corresponding to the target query statement, the updated statement generation model generates an associated statement related to the target query statement.
10. The apparatus according to claim 9, characterized in that, The application module is further configured to perform feature encoding on the target query statement and the response statement respectively through the updated statement generation model to obtain the semantic representation of the target query statement and the semantic representation of the response statement; and generate an associated statement related to the target query statement based on the semantic representation of the target query statement and the semantic representation of the response statement.
11. The apparatus according to claim 10, characterized in that, The updated statement generation model includes an encoder and a decoder; the application module is further configured to perform word segmentation on the target query statement and the response statement respectively through the encoder to obtain a first word sequence corresponding to the target query statement and a second word sequence corresponding to the response statement; to perform feature encoding on the first word sequence and the second word sequence respectively through the encoder to obtain a semantic representation of the target query statement and a semantic representation of the response statement; to use the semantic representation output by the encoder as the input of the decoder, and to determine the target word output at the current time by using the decoded features obtained by the decoder decoding the input semantic representation at the current time and the target words output at each time before the current time; Based on the target words output at each time point, generate associated statements that are related to the target query statement.
12. The apparatus according to any one of claims 7 to 11, characterized in that, The updated statement generation model is applied to the logistics question-and-answer database; the device also includes: The application module is used to obtain logistics query requests for physical items and search for logistics information corresponding to the logistics query request from the logistics question and answer database; call the updated statement generation model to generate multiple associated logistics requests based on the logistics query request and the logistics information; select the associated logistics request that meets the recommendation conditions from the multiple associated logistics requests and display it on the query interface where the logistics query request is located.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
14. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Robot dialogue reply method and device
CN110083693A
Automatic reply generation method for open domain dialogue system
CN110334190A
Interactive lyric generation method and system based on neural network
CN111259665A
Semantic representation model training method and device, equipment and storage medium
CN113408299A