Model training method and device, information recommendation method and device, medium, equipment and program product

By using feature extraction and similarity calculation methods in model training, the tags are dynamically updated and training samples are automatically generated, which solves the problems of high cost of manual annotation and low training efficiency in the prior art, and efficient model training is achieved.

CN119691184AInactive Publication Date: 2025-03-25MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411495593.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2025-03-25
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art requires a large amount of manual labeling of sample data during model training, resulting in high cost and low training efficiency.

Method used

By determining the positive and negative samples, the trained model has the ability to extract features, calculate the similarity between feature vectors, dynamically update the labels, automatically generate training samples, and then train the second model to improve the recognition ability of the model.

Benefits of technology

Automatic generation of training samples is realized, the training efficiency of the model is improved, manual intervention is reduced, and the recognition ability of the model is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119691184A_ABST
    Figure CN119691184A_ABST
Patent Text Reader

Abstract

The invention provides a model training method and device, an information recommendation method and device, a medium, equipment and a program product. The model training method comprises the steps of determining a first positive sample and a first negative sample; the first text and the second text are input into a first model, a first feature vector of the first text and a second feature vector of the second text are obtained, and the first model is obtained through training according to the first positive sample and the first negative sample; calculating the similarity between the first feature vector and the second feature vector to obtain a first similarity; updating the first label of the first positive sample to the first similarity to obtain a second positive sample; calculating a second similarity between the third text and the fourth text, and determining a fifth text from the fourth text according to the second similarity to obtain a second negative sample; and training a second model according to the second positive sample and the second negative sample. According to the method, the training samples can be automatically generated, and the model training efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular, to a model training method, information recommendation method, device, medium, equipment and program product. Background Art

[0002] In related technologies, domain data sets are usually used to fine-tune the model. During the model training process, a large amount of training sample data is required, and the labeling of the sample data needs to be done manually, which often consumes a lot of labor costs, resulting in high costs and low model training efficiency. Summary of the invention

[0003] The purpose of the present disclosure is to provide a model training method, information recommendation method, device, medium, equipment and program product to improve the training efficiency of the model.

[0004] In a first aspect, an embodiment of the present disclosure provides a model training method, comprising: Determine a first positive sample and a first negative sample, where the first positive sample includes: a first text, a second text corresponding to the first text, and a first label; Inputting the first text and the second text into a first model to obtain a first feature vector of the first text and a second feature vector of the second text, wherein the first model is trained based on the first positive sample and the first negative sample; Calculating the similarity between the first feature vector and the second feature vector to obtain a first similarity; Updating the first label of the first positive sample to the first similarity to obtain a second positive sample, where the second positive sample includes the first text, the second text, and the first similarity; Calculating a second similarity between the third text and the fourth text, and determining a fifth text from the fourth text according to the second similarity to obtain a second negative sample, wherein the second negative sample includes the third text, the fifth text, and a second label; A second model is trained according to the first text, the second text, the first similarity, the third text, the fifth text, and the second label.

[0005] In a second aspect, an embodiment of the present disclosure provides an information recommendation method, including: An eighth text is obtained based on the sixth text, a seventh text corresponding to the sixth text, and a second model, wherein the second model is trained according to the model training method provided by any one of the first aspects.

[0006] In a third aspect, the present disclosure provides a model training device, wherein the model training device module: A first processing module is configured to determine a first positive sample and a first negative sample, wherein the first positive sample includes: a first text, a second text corresponding to the first text, and a first label; A second processing module is configured to input the first text and the second text into a first model as a first feature vector to obtain a first feature vector of the first text and a second feature vector of the second text, wherein the first model is trained according to the first positive sample and the first negative sample; A third processing module is configured to calculate the similarity between the first feature vector and the second feature vector to obtain a first similarity; A fourth processing module is configured to update the first label of the first positive sample to the first similarity to obtain a second positive sample, where the second positive sample includes the first text, the second text, and the first similarity; a fifth processing module, configured to calculate a second similarity between the third text and the fourth text, and determine a fifth text from the fourth text according to the second similarity to obtain a second negative sample, wherein the second negative sample includes the third text, the fifth text and a second label; The sixth processing module is configured to train a second model based on the first text, the second text, the first similarity, the third text, the fifth text and the second label.

[0007] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any model training method provided in the first aspect.

[0008] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, including: a memory having a computer program stored thereon; A processor is used to execute the computer program in the memory to implement the steps of the model training method provided in any one of the first aspects.

[0009] In a sixth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of any model training method provided in the first aspect.

[0010] By adopting the above technical scheme, the first model obtained by training the first positive sample and the first negative sample has the feature extraction capability, and the second positive sample is determined according to the first similarity between the first feature vector obtained by the first text in the first positive sample and the second feature vector obtained by the second text in the first positive sample, and the fifth text is determined according to the second similarity between the third text and the fourth text in the first negative sample, thereby obtaining the second negative sample, and the second model is trained based on the second positive sample consisting of the first text, the second text, and the first similarity and the second negative sample consisting of the third text, the fifth text, and the second label. Since the label of the second positive sample is not a fixed binary label, but a first similarity calculated based on the iterative process of model training, it is a dynamically updated label. Different label values ​​will contribute more to the update of model parameters when reflected in the loss value calculation during model training, which will enable the model to learn a more detailed degree of text matching. Since the text in the second negative sample is re-determined after the second similarity during the iterative process of model training, although the label has not changed, the third and fifth texts with high second similarity can be determined, that is, the third and fifth texts that are more easily confused are selected to participate in the training of the second model, which can improve the recognition ability of the model, and the entire process does not require manual intervention, so the automatic generation of training samples can be achieved, and the training efficiency of the model can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings: Figure 1 It is a schematic diagram showing a large language model generating questions based on articles according to an exemplary embodiment.

[0012] Figure 2 The figure is a flowchart of a model training method according to an exemplary embodiment.

[0013] Figure 3 is a schematic diagram of sample changes according to an exemplary embodiment.

[0014] Figure 4 is a sub-step flowchart of step S6 according to an exemplary embodiment.

[0015] Figure 5 It is a schematic diagram of a model training method according to an exemplary embodiment.

[0016] Figure 6 is a flowchart of sub-steps of another step S6 according to an exemplary embodiment.

[0017] Figure 7 It is a schematic diagram of another model training method according to an exemplary embodiment.

[0018] Figure 8 The diagram is a schematic diagram of an information recommendation method according to an exemplary embodiment.

[0019] Fig. 9 It is a block diagram of a model training device according to an exemplary embodiment.

[0020] Fig.10 It is a block diagram of an electronic device according to an exemplary embodiment.

[0021] Fig.11 is a block diagram of another electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0022] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0023] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0024] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0025] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0026] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0027] Feature vector retrieval is mainly used to find the document most similar to the current sentence from a large number of candidate documents. The current mainstream technology mainly uses pre-trained language models such as Bert, RoBERTa or T5 to convert candidate documents and input sentences into feature vectors, and then calculate the similarity to obtain the topK as the final information recommendation result. Directly using open source feature vector retrieval models often does not work well in vertical fields (such as finance, medical care, law, etc.).

[0028] In related technologies, domain data sets are usually used to fine-tune the model. During the model training process, a large amount of training sample data is required, and the labeling of the sample data needs to be done manually, which often consumes a lot of labor costs, resulting in high costs and low model training efficiency.

[0029] In a specific information recommendation scenario, using a large language model (LLM) to generate training samples is a mainstream direction. It is often based on optimizing prompts to generate target samples. LLM can generate multiple questions based on an article. Its purpose is to generate answers to each question that can be found in the article. However, in the actual generation process, the answers to some questions may not be in this article. For example, Figure 1 The bold questions 2 and 5 in Figure 1 are shown in Figure 1. Therefore, the training data generated by LLM is not very controllable and contains noisy samples, which ultimately affects the training effect.

[0030] In order to solve the above-mentioned technical problems, the first model obtained by training the first positive sample and the first negative sample has feature extraction capability, and the second positive sample is determined according to the first similarity between the first feature vector obtained by the first text in the first positive sample and the second feature vector obtained by the second text in the first positive sample, and the fifth text is determined according to the second similarity between the third text and the fourth text in the first negative sample, thereby obtaining the second negative sample, and the second model is trained based on the second positive sample consisting of the first text, the second text, and the first similarity and the second negative sample consisting of the third text, the fifth text, and the second label. Since the label of the second positive sample is not a fixed binary label, but a first similarity calculated based on the iterative process of model training, it is a dynamically updated label. Different label values ​​will contribute more to the update of model parameters when reflected in the loss value calculation during model training, which will enable the model to learn a more detailed degree of text matching. Since the text in the second negative sample is re-determined after the second similarity during the iterative process of model training, although the label has not changed, the third and fifth texts with high second similarity can be determined, that is, the third and fifth texts that are more easily confused are selected to participate in the training of the second model, which can improve the recognition ability of the model, and the entire process does not require manual intervention, so the automatic generation of training samples can be achieved, and the training efficiency of the model can be improved.

[0031] Figure 2 is a flow chart of a model training method according to an exemplary embodiment. The model training method can be applied to electronic devices. Figure 2 , the model training method may include steps S1 to S6.

[0032] Step S1, determining a first positive sample and a first negative sample, where the first positive sample includes: a first text, a second text corresponding to the first text, and a first label.

[0033] The first label may be used to indicate that the second text is an information recommendation text of the first text. The first label may be indicated by the number 1. The first positive sample may be in the form of <first text, second text, 1>.

[0034] For example, the first text may be a question, the second text may be a text segment, and the first tag indicates that the text segment is an information recommendation text for the question, for example, the text segment contains an answer to the question.

[0035] The first positive sample can be generated based on the preset text and the preset prompt words, and the prompt words are used to guide the large model to generate questions with the preset text as the answer. The preset text can be any form of text data, such as a description, an article or a story. The preset prompt words are used to guide the large model to generate keywords or phrases for the question. The role of the prompt words is to help the model focus on specific information or concepts in the preset text, so as to generate questions related to this information or concepts.

[0036] For example, for a preset text, use Query Generator to generate 5 questions. You can use the qwen-14B large model as the Query Generator, and the prompt is as follows: preset text information {passage}\n\nGenerate questions based on the above preset text information, and require that the generated questions can cover the main points of the preset text. Use the generated questions as the first text of the first positive sample, the preset text as the second text, and set the first label to 1 to construct the first positive sample.

[0037] The first negative sample includes: the ninth text, the tenth text, and the second label.

[0038] The second label may be used to indicate that the tenth text is not the information recommendation text of the ninth text. The second label may be indicated by the number 0. The first negative sample may be in the form of <ninth text, tenth text, 0>.

[0039] For example, the ninth text may be a question, the tenth text may be a text paragraph, and the second label indicates that the text paragraph is not an information recommendation text for the question, for example, the text paragraph does not contain an answer to the question.

[0040] For the first negative sample, the BM25 algorithm can be used to retrieve the top 10 similar texts from other non-preset texts. The problem in the first positive sample generated above is used as the problem of the first negative sample, that is, the ninth text. The top 10 similar texts are retrieved from other non-preset texts as the tenth text. The second label is set to 0 to construct the first negative sample.

[0041] In another embodiment, the problem of the first negative sample may be different from the problem of the first positive sample. The first positive sample and the first negative sample may also be generated and obtained in other ways, which are not limited in this embodiment.

[0042] Step S2, inputting the first text and the second text into a first model to obtain a first feature vector of the first text and a second feature vector of the second text, wherein the first model is trained based on a first positive sample and a first negative sample.

[0043] The first model can be a vectorization model that can convert text into a mathematical vector representation. The first model can preprocess the input text first, and then vectorize the preprocessed text. The text preprocessing can be first word segmentation, that is, using word segmentation tools (such as jieba, HanLP, etc.) to divide continuous text into meaningful words or phrases, and then remove useless information in the text, such as punctuation, stop words, etc., and then convert the text into a unified format. The text vectorization processing can be through word embedding or context embedding to convert discrete text data into a dense vector representation.

[0044] The first text is input into the first model to obtain a first feature vector of the first text.

[0045] The first model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input first text, and then performs vectorization processing on the preprocessed text to obtain a first feature vector of the first text.

[0046] The second text is input into the first model to obtain a second feature vector of the second text.

[0047] The first model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input second text, and then vectorizes the preprocessed text to obtain a second feature vector of the second text. The first model is trained according to the first positive sample and the first negative sample until the training stop condition is met to obtain a trained first model. The training stop condition can be that the number of iterations of the first model reaches a set number, or that the loss function converges or is less than a set value, or that the training time reaches a set time, which is not limited in this embodiment.

[0048] The first model is trained by the first positive sample and the first negative sample until the first model meets the training stop condition, so that the trained first model can effectively learn the rules in the first positive sample and the first negative sample, and due to the setting of the training stop condition, meaningless iterations are avoided and prevented, saving computing resources and time.

[0049] Step S3, calculating the similarity between the first feature vector and the second feature vector to obtain a first similarity.

[0050] The cosine similarity between the first eigenvector and the second eigenvector is calculated to obtain a first similarity, and the value range of the first similarity may be 0 to 1. The larger the value of the first similarity is, the higher the similarity between the first eigenvector and the second eigenvector is.

[0051] It should be understood that to calculate the cosine similarity between the first eigenvector and the second eigenvector, the dot product between the first eigenvector and the second eigenvector can be calculated first, then the product of the modulus of the first eigenvector and the modulus of the second eigenvector is calculated, and finally the ratio of the dot product to the product of the modulus is calculated to obtain the first similarity.

[0052] In other embodiments, the first similarity may also be the Euclidean distance, Manhattan distance, Jaccard similarity, etc. between the first feature vector and the second feature vector.

[0053] Step S4: Update the first label of the first positive sample to the first similarity to obtain a second positive sample, where the second positive sample includes the first text, the second text and the first similarity.

[0054] The first positive sample includes the first text, the second text corresponding to the first text, and the first label. The first label in the first positive sample is updated to the first similarity, and the obtained second positive sample includes the first text, the second text corresponding to the first text, and the first similarity. Figure 3 , the change process from the first positive sample to the second positive sample can be expressed as Figure 3 As shown, A1 represents the first text, A2 represents the second text, C1 represents the first label, and D1 represents the first similarity. The second positive sample can be obtained by updating the first label in the first positive sample to the first similarity.

[0055] The second positive sample may be in the form of <first text, second text, first similarity>.

[0056] Step S5, calculating the second similarity between the third text and the fourth text, and determining the fifth text from the fourth text according to the second similarity to obtain a second negative sample, wherein the second negative sample includes the third text, the fifth text and the second label.

[0057] See also Figure 3 , the process of generating the second negative sample can be as follows Figure 3 As shown, A3 represents the third text, A4 represents the fourth text, A5 represents the fifth text, A9 represents the ninth text, A10 represents the tenth text, and C2 represents the second label. The fourth text is modified to the fifth text to obtain the second negative sample. The second negative sample and the first negative sample both contain the second label. The third text and the ninth text can be the same or different, which is not limited in this embodiment.

[0058] The third text is input into the first model to obtain a ninth feature vector of the third text.

[0059] The first model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input third text, and then performs vectorization on the preprocessed text to obtain the ninth feature vector of the third text. The fourth text is input into the first model to obtain the tenth feature vector of the fourth text.

[0060] The first model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input fourth text, and then performs vectorization on the preprocessed text to obtain the tenth feature vector of the fourth text. The second label can be used to indicate that the fifth text is not an information recommendation text of the third text. The second label can be indicated by the number 0.

[0061] The second negative sample may be in the form of <third text, fifth text, 0>.

[0062] The cosine similarity between the ninth eigenvector and the tenth eigenvector is calculated to obtain a second similarity, and the value range of the second similarity may be 0 to 1. The larger the value of the second similarity is, the higher the similarity between the ninth eigenvector and the tenth eigenvector is.

[0063] It should be understood that the cosine similarity between the ninth eigenvector and the tenth eigenvector can be calculated by first calculating the dot product between the ninth eigenvector and the tenth eigenvector, then calculating the product of the modulus of the ninth eigenvector and the modulus of the tenth eigenvector, and finally calculating the ratio of the dot product to the product of the modulus to obtain the second similarity.

[0064] In other embodiments, the second similarity may also be the Euclidean distance, Manhattan distance, Jaccard similarity, etc. between the ninth eigenvector and the tenth eigenvector.

[0065] The second similarity is compared with a similarity threshold, and when the second similarity is greater than the similarity threshold, the fourth text corresponding to the second similarity is determined as the fifth text.

[0066] In other embodiments, the second similarities may be arranged from large to small, and the fourth texts corresponding to the first N second similarities are all determined as the fifth texts. For example, N is 10. It should be understood that by setting a proper lower similarity threshold and increasing N, the number of fifth texts may be increased, more fifth texts may be obtained, and more second negative samples may be generated for training the second model, thereby improving the robustness of the second model.

[0067] A second negative sample with a high second similarity is determined through the second similarity between the third text and the fourth text, so as to enhance the discrimination ability of the second model and improve the generalization ability of the second model during the training process.

[0068] Step S6, training a second model according to the first text, the second text, the first similarity, the third text, the fifth text and the second label.

[0069] The second model is trained according to a second positive sample consisting of the first text, the second text, and the first similarity, and a second negative sample consisting of the third text, the fifth text, and the second label.

[0070] The second model is trained according to the second positive sample and the second negative sample. When the performance of the second model does not meet the preset performance conditions, if the training of the second model meets the training stop condition, the first model is updated to the second model, and the step of inputting the first text and the second text into the first model to obtain the first feature vector of the first text and the second feature vector of the second text is returned to execute until the performance of the second model meets the preset performance conditions, thereby obtaining the trained second model.

[0071] Specifically, the second model is trained according to the second positive sample and the second negative sample, and it is determined whether the performance of the second model meets the preset performance conditions. If the performance of the second model meets the preset performance conditions, a trained second model is obtained. If the performance of the second model does not meet the preset performance conditions, it is determined whether the training of the second model meets the training stop conditions. If the second model does not meet the training stop conditions, the second model is trained according to the second positive sample and the second negative sample until the performance of the second model meets the preset performance conditions or the training of the second model meets the training stop conditions. If the training of the second model meets the training stop conditions, the first model is updated to the second model, and the first text and the second text are input into the first model to obtain the first feature vector of the first text and the second feature vector of the second text, until the performance of the second model meets the preset performance conditions, and the trained second model is obtained.

[0072] The preset performance condition may be that the loss function of the second model converges or is less than a set value.

[0073] The training stop condition may be that the number of iterations of the second model reaches a set number, or that the training time of the second model reaches a set time.

[0074] It should be understood that the set value, set number of times, and set duration in the conditions set for training the first model may be the same as or different from the set value, set number of times, and set duration in the conditions set for training the second model. Users may set them according to actual conditions, and this embodiment does not limit this.

[0075] It should be understood that the training stop condition of the second model is generally easier to achieve than the preset performance condition. The set value, set number of times, and set duration in the conditions set for training the first model may be the same as or different from the set value, set number of times, and set duration in the conditions set for training the second model. The user may set them according to actual conditions, and this embodiment does not limit them here.

[0076] In another embodiment, the number of layers of the second model is less than or equal to the number of layers of the first model, that is, the number of layers of the second model may be equal to the number of layers of the first model, or the number of layers of the second model may be less than the number of layers of the first model.

[0077] It should be understood that the number of layers of the second model is equal to the number of layers of the first model, the number of model layers does not change during the replacement iteration cycle, and the number of layers of the second model finally trained is the same as the number of layers of the initial second model and the number of layers of the initial first model.

[0078] In some embodiments, the initial first model is the same as the initial second model. Here, the initial first model and the initial second model can be understood as the first model before training and the second model before training.

[0079] The number of layers of the second model is smaller than that of the first model. The number of layers of the initial second model may be smaller than that of the initial first model. After the step of updating the first model to the second model is executed for the first time, the number of layers of the new first model changes and becomes the number of layers of the initial second model. In the subsequent training process, the number of layers of the first model and the second model no longer changes, and the number of layers of the second model finally trained is the same as the number of layers of the initial second model.

[0080] For example, the first model can be a teacher model, and the second model can be a student model. The first model has 12 layers, and the second model has 6 layers. After the first step of updating the first model to the second model is executed, the number of layers of the new first model becomes 6 layers. In the subsequent training process, the number of layers of the first model and the second model are both 6 layers and no longer change. The number of layers of the second model after the final training is 6 layers.

[0081] Through learning and training with the initial first model with a large number of layers, the rules in the first positive sample and the first negative sample are better obtained, and then the rules are passed to the second model with a small number of layers for model compression, so as to achieve knowledge distillation and improve the efficiency of model training. In addition, training samples are generated based on the large model, and the quality of the generated samples is gradually purified through the method of automatic repeated iterative training of the first model and the second model, which solves the interference of noise samples generated by the large model on the model and improves the model effect.

[0082] The first model obtained by training with the first positive sample and the first negative sample has feature extraction capability. The second positive sample is determined based on the first similarity between the first feature vector obtained from the first text in the first positive sample and the second feature vector obtained from the second text in the first positive sample. The fifth text is determined based on the second similarity between the third text and the fourth text in the first negative sample, thereby obtaining the second negative sample. The second model is trained based on the second positive sample consisting of the first text, the second text, and the first similarity and the second negative sample consisting of the third text, the fifth text, and the second label. Since the label of the second positive sample is not a fixed binary label, but a first similarity calculated based on the iterative process of model training, it is a dynamically updated label. Different label values ​​will contribute more to the update of model parameters when reflected in the loss value calculation during model training, which will enable the model to learn a more detailed degree of text matching. Since the text in the second negative sample is re-determined after the second similarity during the iterative process of model training, although the label has not changed, the third and fifth texts with high second similarity can be determined, that is, the third and fifth texts that are more easily confused are selected to participate in the training of the second model, which can improve the recognition ability of the model, and the entire process does not require manual intervention, so the automatic generation of training samples can be achieved, and the training efficiency of the model can be improved.

[0083] In one embodiment, see Figure 4 , Figure 4 1 is a flowchart of sub-steps of step S6 according to an exemplary embodiment. Step S6 may train a second model according to a second positive sample, and may include steps S601 to S605.

[0084] Step S601, input the first text and the second text into the second model to obtain the third feature vector of the first text and the fourth feature vector of the second text. The second model can be a vectorization model that can convert the text into a mathematical vector representation. The second model can first perform text preprocessing on the input text, and then vectorize the preprocessed text. The text preprocessing can be first performing word segmentation processing, that is, using a word segmentation tool (for example, jieba, HanLP, etc.) to divide the continuous text into meaningful words or phrases, and then remove useless information in the text, such as punctuation marks, stop words, etc., and then convert the text into a unified format. The text vectorization processing can be to convert discrete text data into a dense vector representation by word embedding or context embedding.

[0085] The first text is input into the second model to obtain a third feature vector of the first text.

[0086] The second model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input first text, and then performs vectorization on the preprocessed text to obtain the third feature vector of the first text. The second text is input into the second model to obtain the fourth feature vector of the second text.

[0087] The second model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input second text, and then performs vectorization processing on the preprocessed text to obtain a fourth feature vector of the second text.

[0088] Step S602: normalize the third eigenvector and the fourth eigenvector to obtain a first predicted label.

[0089] The third eigenvector and the fourth eigenvector are feature-fused to obtain a first fused feature vector, which may include a concatenated feature vector of the third eigenvector and the fourth eigenvector, and may also include a difference feature vector of the third eigenvector and the fourth eigenvector.

[0090] In another embodiment, before feature fusion, the third feature vector and the fourth feature vector may be pooled respectively to more effectively capture key information of the first text and the second text and enhance generalization capability.

[0091] The first fused feature vector is input into a normalization layer (eg, a Softmax layer), that is, the first fused feature vector is converted into a probability distribution, and a probability value is obtained, which is the first predicted label.

[0092] Step S603: Calculate a first loss value according to the first predicted label and the first similarity.

[0093] The first loss value may be a cross entropy loss between the first predicted label and the first similarity.

[0094] For a binary classification problem, the cross entropy loss can generally be expressed as: Loss = -(ylog(p)+(1-y)log(1-p)) Where y is the true label (0 or 1) and p is the probability that the model predicts that the sample is class 1.

[0095] In this embodiment, y is the first similarity and p is the first predicted label.

[0096] Step S604, calculating a second loss value according to the third eigenvector, the fourth eigenvector, the first eigenvector and the second eigenvector.

[0097] The third eigenvector and the fourth eigenvector are feature-fused to obtain a first fused feature vector, which may include a concatenated feature vector of the third eigenvector and the fourth eigenvector, and may also include a difference feature vector of the third eigenvector and the fourth eigenvector.

[0098] The first feature vector and the second feature vector are feature-fused to obtain a second fused feature vector, which may include a concatenated feature vector of the first feature vector and the second feature vector, and may also include a difference feature vector between the first feature vector and the second feature vector.

[0099] In another embodiment, before feature fusion, the first feature vector, the second feature vector, the third feature vector and the fourth feature vector may be pooled respectively to more effectively capture key information of the first text and the second text and enhance generalization capability.

[0100] The second loss value may be a KL divergence loss between the first fused feature vector and the second fused feature vector.

[0101] Step S605: train the second model according to the first loss value and the second loss value.

[0102] The parameters of the second model are adjusted with the goal of minimizing the sum of the first loss value and the second loss value.

[0103] For example, an optimization algorithm such as SGD, Adam, RMSprop, etc. is selected to update the second model parameters. Hyperparameters such as learning rate, batch size, number of training cycles (epochs), and early stopping parameters are determined. The weights and biases of the second model are randomly initialized. For each epoch: a. Input the first text and the second text to the second model for forward propagation. b. Determine the first loss value and the second loss value. c. Perform backpropagation and calculate the gradient of the loss relative to the model parameters. d. Update the second model parameters according to the gradient using the selected optimization algorithm.

[0104] In the process of training the second model according to the second positive sample, since the label of the second positive sample is not a fixed binary label, but a first similarity calculated based on the iterative process of model training, it is a dynamically updated label. The different label values ​​are reflected in the loss value calculation in the model training process. The difference in contribution to the update of model parameters will be greater, which will enable the model to learn a more detailed degree of text matching. The KL divergence loss function is added for constraint, so that the distribution between the first model and the second model will not be very different, thereby enhancing the stability of the second model training.

[0105] In one embodiment, see Figure 5, the model training process based on positive samples is as follows: 1.1 Input the first positive sample and the first negative sample into the first model for training; 1.2 Get the first model after training; 2.1 Input the first positive sample into the first trained model to obtain the first vector and the second vector , and calculate the first similarity; 2.2 Get the second positive sample; 3.1 Input the second positive sample into the second model to obtain the third vector and the fourth vector ; The third vector and the fourth vector Input the first fused feature vector into the feature fusion layer for feature fusion, and obtain the first fused feature vector; then input the first fused feature vector into the Softmax layer to obtain the first predicted label; calculate the first loss value according to the first predicted label and the first similarity; and the second vector The feature is input into the feature fusion layer for feature fusion to obtain a second fused feature vector; a second loss value can be obtained according to the first fused feature vector and the second fused feature vector; and the parameters of the second model are adjusted according to the first loss value and the second loss value.

[0106] Determine whether the second model meets the preset performance conditions. If the second model meets the preset performance conditions, obtain the trained second model. If the second model does not meet the preset performance conditions, continue to determine whether the second model meets the training stop conditions. If the second model meets the training stop conditions, replace the first model with the second model at this time, and loop through steps 2.1 and 2.1. If the second model does not meet the training stop conditions, return to the step of training the second model according to the second positive sample until the performance of the second model meets the preset performance conditions or the training of the second model meets the training stop conditions.

[0107] In one embodiment, see Figure 6 , Figure 6 2 is another sub-step flow chart of step S6 according to an exemplary embodiment. Step S6 may train a second model according to a second negative sample, and may include steps S606 to S611.

[0108] Step S606: input the third text and the fifth text into the first model to obtain a fifth feature vector of the third text and a sixth feature vector of the fifth text.

[0109] The first model can be a vectorization model that can convert text into a mathematical vector representation. The first model can perform text preprocessing on the input text first, and then perform text vectorization processing. The text preprocessing can be first performing word segmentation processing, that is, using word segmentation tools (such as jieba, HanLP, etc.) to divide continuous text into meaningful words or phrases, and then remove useless information in the text, such as punctuation, stop words, etc., and then convert the text into a unified format. The text vectorization processing can be through word embedding or context embedding to convert discrete text data into a dense vector representation.

[0110] The third text is input into the first model to obtain a fifth feature vector of the third text.

[0111] The first model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input third text, and then performs vectorization on the preprocessed text to obtain a fifth feature vector of the third text. The fifth text is input into the first model to obtain a sixth feature vector of the fifth text.

[0112] The first model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input fifth text, and then performs vectorization processing on the preprocessed text to obtain a sixth feature vector of the fifth text.

[0113] Step S607: input the third text and the fifth text into the second model to obtain the seventh feature vector of the third text and the eighth feature vector of the fifth text.

[0114] The second model can be a vectorization model that can convert text into a mathematical vector representation. The second model can preprocess the input text first, and then vectorize the preprocessed text. The text preprocessing can be first word segmentation, that is, using word segmentation tools (such as jieba, HanLP, etc.) to divide continuous text into meaningful words or phrases, and then remove useless information in the text, such as punctuation, stop words, etc., and then convert the text into a unified format. The text vectorization processing can be through word embedding or context embedding to convert discrete text data into a dense vector representation.

[0115] The third text is input into the second model to obtain the seventh feature vector of the third text.

[0116] The second model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input third text, and then vectorizes the preprocessed text to obtain the seventh feature vector of the third text.

[0117] The fifth text is input into the second model to obtain an eighth feature vector of the fifth text.

[0118] The second model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input fifth text, and then performs vectorization processing on the preprocessed text to obtain an eighth feature vector of the fifth text.

[0119] Step S608: normalize the seventh eigenvector and the eighth eigenvector to obtain a second predicted label.

[0120] The seventh eigenvector and the eighth eigenvector are feature-fused to obtain a third fused feature vector, which may include a concatenated feature vector of the seventh eigenvector and the eighth eigenvector, and may also include a difference feature vector of the seventh eigenvector and the eighth eigenvector.

[0121] In another embodiment, before feature fusion, the seventh feature vector and the eighth feature vector may be pooled respectively to more effectively capture key information of the third text and the fifth text and enhance generalization capability.

[0122] The third fused feature vector is input into a normalization layer (eg, a softmax layer), that is, the third fused feature vector is converted into a probability distribution, and a probability value is obtained, which is the second prediction label.

[0123] Step S609, calculating a third loss value according to the second predicted label and the second label.

[0124] The third loss value may be a cross entropy loss between the second predicted label and the second label.

[0125] Step S610, calculating a fourth loss value according to the fifth eigenvector, the sixth eigenvector, the seventh eigenvector and the eighth eigenvector.

[0126] The seventh eigenvector and the eighth eigenvector are feature-fused to obtain a third fused feature vector, which may include a concatenated feature vector of the seventh eigenvector and the eighth eigenvector, and may also include a difference feature vector of the seventh eigenvector and the eighth eigenvector.

[0127] The fifth eigenvector and the sixth eigenvector are feature-fused to obtain a fourth fused feature vector, which may include a concatenated feature vector of the fifth eigenvector and the sixth eigenvector, and may also include a difference feature vector of the fifth eigenvector and the sixth eigenvector.

[0128] In another embodiment, before feature fusion, the fifth feature vector, the sixth feature vector, the seventh feature vector and the eighth feature vector may be pooled respectively to more effectively capture key information of the third text and the fifth text and enhance generalization capability.

[0129] The fourth loss value may be a KL divergence loss between the third fused feature vector and the fourth fused feature vector.

[0130] Step S611, training the second model according to the third loss value and the fourth loss value.

[0131] With the goal of minimizing the sum of the third loss value and the fourth loss value, the parameters of the second model are adjusted.

[0132] For example, an optimization algorithm such as SGD, Adam, RMSprop, etc. is selected to update the second model parameters. Hyperparameters such as learning rate, batch size, number of training cycles (epochs), and early stopping parameters are determined. The weights and biases of the second model are randomly initialized. For each epoch: a. Input the third text and the fifth text to the second model for forward propagation. b. Determine the third loss value and the fourth loss value. c. Perform backpropagation and calculate the gradient of the loss relative to the model parameters. d. Update the second model parameters according to the gradient using the selected optimization algorithm.

[0133] In the process of training the second model according to the second negative sample, since the text in the second negative sample is re-determined through the second similarity in the model training iteration process, although the label has not changed, the third text and the fifth text with high second similarity can be determined, that is, the third text and the fifth text that are more easily confused are selected to participate in the training of the second model, which can improve the recognition ability of the model, and the KL divergence loss function is added for constraint, so that the distribution between the first model and the second model will not produce a big difference, thereby enhancing the stability of the second model training.

[0134] In one embodiment, see Figure 7 , the model training process based on negative samples is as follows: 1.1 Input the first positive sample and the first negative sample into the first model for training; 1.2 Get the first model after training; 2.1 Input the third text and the fourth text into the trained first model to obtain the ninth vector and the tenth vector, calculate the second similarity, determine the fifth text according to the second similarity, and combine it with the second label in the first negative sample; 2.2 Get the second negative sample; 3.1 Input the second negative sample into the second model to obtain the seventh vector and the eighth vector ; Input the second negative sample into the trained first model to obtain the fifth vector and the sixth vector ; The seventh vector and the eighth vector Input to the feature fusion layer for feature fusion to obtain the third fused feature vector; Then input the third feature fusion vector into the Softmax layer to obtain the second prediction label; calculate the third loss value based on the second prediction label and the second label; and the sixth vector The feature fusion layer performs feature fusion to obtain a fourth fused feature vector; a fourth loss value can be obtained according to the third fused feature vector and the fourth fused feature vector; and the parameters of the second model are adjusted according to the third loss value and the fourth loss value.

[0135] Determine whether the second model meets the preset performance conditions. If the second model meets the preset performance conditions, obtain the trained second model. If the second model does not meet the preset performance conditions, continue to determine whether the second model meets the training stop conditions. If the second model meets the training stop conditions, replace the first model with the second model at this time, and loop through steps 2.1 and 2.1. If the second model does not meet the training stop conditions, return to the step of training the second model according to the second negative sample until the performance of the second model meets the preset performance conditions or the training of the second model meets the training stop conditions.

[0136] It should be understood that in Figure 5 and Figure 7 In order to describe the whole process clearly, the positive and negative samples are split. In the actual training process, both positive and negative samples will participate in the training of the model.

[0137] In a possible implementation, after step S4, the model training method may further include: The second text is subjected to noise processing to obtain a noisy second text.

[0138] The noise adding method may include randomly inserting some words or phrases, randomly exchanging the order of some words, randomly deleting some words, replacing some words with synonyms, adding some noise words, etc.

[0139] For example, 5% of the words in the second text are randomly replaced by synonyms, and 5% of the words in the second text are randomly masked.

[0140] By performing noise processing on the second text and using the noise-processed second text to participate in the training process of the second model, the robustness of the second model can be further enhanced.

[0141] Based on the same inventive concept, the embodiment of the present disclosure further provides an information recommendation method, which includes: The eighth text is obtained according to the sixth text, the seventh text corresponding to the sixth text, and the second model, wherein the second model is trained according to the above-mentioned model training method.

[0142] The second model can be a vectorization model that can convert text into a mathematical vector representation. The second model can preprocess the input text first, and then vectorize the preprocessed text. The text preprocessing can be first word segmentation, that is, using a word segmentation tool (for example, jieba, HanLP, etc.) to divide the continuous text into meaningful words or phrases, and then remove useless information in the text, such as punctuation, stop words, etc., and then convert the text into a unified format. The text vectorization process can be to convert discrete text data into a dense vector representation by word embedding or context embedding. According to the sixth text, the seventh text corresponding to the sixth text, and the second model, the eighth text is obtained. It can be understood that the sixth text is input into the second model to obtain the eleventh feature vector of the sixth text, the seventh text is input into the second model to obtain the twelfth feature vector of the seventh text, and the similarity between the eleventh feature vector and the twelfth feature vector is calculated. When the similarity meets certain conditions, the seventh text is output as the eighth text for information recommendation.

[0143] The sixth text is input into the second model to obtain the eleventh feature vector of the sixth text.

[0144] The second model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input sixth text, and then vectorizes the preprocessed text to obtain the eleventh feature vector of the sixth text.

[0145] The seventh text is input into the second model to obtain the twelfth feature vector of the seventh text.

[0146] The second model performs text preprocessing such as word segmentation, removal of useless information, and standardization on the input seventh text, and then vectorizes the preprocessed text to obtain the twelfth feature vector of the seventh text.

[0147] The similarity between the eleventh feature vector and the twelfth feature vector is calculated, and when the similarity satisfies a certain condition, the seventh text is output as an eighth text for information recommendation.

[0148] Calculating the similarity between the eleventh eigenvector and the twelfth eigenvector can be understood as calculating the cosine similarity between the eleventh eigenvector and the twelfth eigenvector, that is, first calculating the dot product between the eleventh eigenvector and the twelfth eigenvector, then calculating the product of the modulus of the eleventh eigenvector and the modulus of the twelfth eigenvector, and finally calculating the ratio of the dot product to the product of the modulus, so as to obtain the cosine similarity between the eleventh eigenvector and the twelfth eigenvector.

[0149] In other embodiments, the similarity between the eleventh eigenvector and the twelfth eigenvector may also be the Euclidean distance, Manhattan distance, Jaccard similarity, etc. between the eleventh eigenvector and the twelfth eigenvector.

[0150] When the similarity meets certain conditions, the seventh text is output as the eighth text for information recommendation. It can be understood that when the similarity is greater than a preset similarity threshold, the seventh text is output as the eighth text for information recommendation.

[0151] In other embodiments, multiple similarities may be compared, and the first K (K is an integer) seventh texts with the largest similarities are selected as the eighth text for information recommendation.

[0152] In one embodiment, see Figure 8First, the sixth text may be a user question, and the seventh text may be a document slicing result. The user question and multiple document slicing results are input into the trained second model to obtain a user question feature vector and multiple document slicing feature vectors. The document slicing result may be a model input context length limit. If all document data cannot be input into the model at once, the text in the document may be cut into segments, i.e., document slicing results. The number of characters in each document slicing result may be set to not exceed 1024. The user question is input into the trained second model to obtain a user question feature vector. For each document slicing result, the document slicing result is input into the trained second model to obtain a document slicing feature vector. In this way, multiple document slicing feature vectors are obtained. Secondly, the question-answer similarity between the user question feature vector and each document slicing feature vector is determined. The cosine similarity between the user question feature vector and each document slicing feature vector is calculated as the question-answer similarity. Then, the target question-answer similarity is determined from the multiple question-answer similarities, and the document slicing result corresponding to the document slicing feature vector of the target question-answer similarity is used as the target answer information for information recommendation. Compare multiple question-answer similarities with a preset similarity. When the question-answer similarity is greater than the preset similarity, the document slicing result corresponding to the document slicing feature vector of the question-answer similarity is used as the target answer information for the user's question. In another embodiment, multiple question-answer similarities can also be arranged from large to small, and the document slicing results corresponding to the document slicing feature vectors of the first K question-answer similarities are used as the target answer information for information recommendation. For example, K is 3.

[0153] Based on the same inventive concept, the present disclosure also provides a model training device, which can be applied to electronic devices. Fig. 9 , the model training device 800 may include: The first processing module 801 is configured to determine a first positive sample and a first negative sample, where the first positive sample includes: a first text, a second text corresponding to the first text, and a first label; The second processing module 802 is configured to input the first text and the second text into a first model as a first feature vector to obtain a first feature vector of the first text and a second feature vector of the second text, wherein the first model is trained according to the first positive sample and the first negative sample; The third processing module 803 is configured to calculate the similarity between the first feature vector and the second feature vector to obtain a first similarity; The fourth processing module 804 is configured to update the first label of the first positive sample to the first similarity to obtain a second positive sample, where the second positive sample includes the first text, the second text and the first similarity; A fifth processing module 805 is configured to calculate a second similarity between the third text and the fourth text, and determine the fifth text from the fourth text according to the second similarity to obtain a second negative sample, wherein the second negative sample includes the third text, the fifth text and the second label; The sixth processing module 806 is configured to train a second model according to the first text, the second text, the first similarity, the third text, the fifth text and the second label.

[0154] Optionally, the sixth processing module 806 includes: A first sub-processing module is configured to input the first text and the second text into a second model to obtain a third feature vector of the first text and a fourth feature vector of the second text; A second sub-processing module is configured to perform normalization processing on the third eigenvector and the fourth eigenvector to obtain a first prediction label; A third sub-processing module is configured to calculate a first loss value according to the first predicted label and the first similarity; a fourth sub-processing module, configured to calculate a second loss value according to the third eigenvector, the fourth eigenvector, the first eigenvector, and the second eigenvector; The fifth sub-processing module is configured to train the second model according to the first loss value and the second loss value.

[0155] Optionally, the sixth processing module 806 includes: a sixth sub-processing module, configured to input the third text and the fifth text into the first model to obtain a fifth feature vector of the third text and a sixth feature vector of the fifth text; a seventh sub-processing module, configured to input the third text and the fifth text into the second model to obtain a seventh feature vector of the third text and an eighth feature vector of the fifth text; an eighth sub-processing module, configured to perform normalization processing on the seventh eigenvector and the eighth eigenvector to obtain a second predicted label; A ninth sub-processing module, configured to calculate a third loss value according to the second predicted label and the second label; a tenth sub-processing module, configured to calculate a fourth loss value according to the fifth eigenvector, the sixth eigenvector, the seventh eigenvector, and the eighth eigenvector; The eleventh sub-processing module is configured to train the second model according to the third loss value and the fourth loss value.

[0156] Optionally, the first tag is used to indicate that the second text is an information recommendation text of the first text; and the second tag is used to indicate that the fifth text is not an information recommendation text of the third text.

[0157] Optionally, the model training device 800 may further include: The seventh processing module is configured to perform noise processing on the second text to obtain the noisy second text.

[0158] Regarding the model training device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the model training method, and will not be elaborated here.

[0159] Fig.10 1 is a block diagram of an electronic device 1900 according to an exemplary embodiment. For example, the electronic device 1900 may be provided as a server. Fig.10 The electronic device 1900 includes a first processor 1922, which may be one or more, and a first memory 1932 for storing a computer program executable by the first processor 1922. The computer program stored in the first memory 1932 may include one or more modules each corresponding to a set of instructions. In addition, the first processor 1922 may be configured to execute the computer program to perform the above-mentioned model training method.

[0160] In addition, the electronic device 1900 may further include a power supply component 1926 and a first communication component 1950, the power supply component 1926 may be configured to perform power management of the electronic device 1900, and the first communication component 1950 may be configured to implement communication of the electronic device 1900, for example, wired or wireless communication. In addition, the electronic device 1900 may further include an input / output (I / O) interface 1958. The electronic device 1900 may operate based on an operating system stored in the first memory 1932, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, etc.

[0161] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned model training method are implemented. For example, the computer-readable storage medium can be the above-mentioned first memory 1932 including program instructions, and the above-mentioned program instructions can be executed by the first processor 1922 of the electronic device 1900 to complete the above-mentioned model training method.

[0162] Fig.11 FIG. 7 is a block diagram of another electronic device 700 according to an exemplary embodiment. Fig.11 As shown, the electronic device 700 may include: a second processor 701 , a second memory 702 . The electronic device 700 may also include one or more of a multimedia component 703 , an input / output (I / O) interface 704 , and a second communication component 705 .

[0163] Among them, the second processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned model training method. The second memory 702 is used to store various types of data to support the operation of the electronic device 700, and these data may include, for example, instructions for any application or method used to operate on the electronic device 700, and application-related data, such as contact data, messages sent and received, pictures, audio, video, etc. The second memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone, which is used to receive external audio signals. The received audio signal may be further stored in the second memory 702 or sent through the second communication component 705. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 704 provides an interface between the second processor 701 and other interface modules, and the above-mentioned other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The second communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding second communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module.

[0164] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned model training method.

[0165] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned model training method are implemented. For example, the computer-readable storage medium can be the above-mentioned second memory 702 including program instructions, and the above-mentioned program instructions can be executed by the second processor 701 of the electronic device 700 to complete the above-mentioned model training method.

[0166] Based on the same concept, an embodiment of the present disclosure also provides a computer program product, including a computer program, which implements the steps of the above-mentioned model training method when executed by a processor.

[0167] It should be understood that the above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) to form a technical solution.

[0168] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0169] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims

1. A model training method, characterized in that: include: Determine a first positive sample and a first negative sample, where the first positive sample includes a first text, a second text corresponding to the first text, and a first label; Inputting the first text and the second text into a first model to obtain a first feature vector of the first text and a second feature vector of the second text, wherein the first model is trained based on the first positive sample and the first negative sample; Calculating the similarity between the first feature vector and the second feature vector to obtain a first similarity; Updating the first label of the first positive sample to the first similarity to obtain a second positive sample, where the second positive sample includes the first text, the second text, and the first similarity; Calculating a second similarity between the third text and the fourth text, and determining a fifth text from the fourth text according to the second similarity to obtain a second negative sample, wherein the second negative sample includes the third text, the fifth text, and a second label; A second model is trained according to the first text, the second text, the first similarity, the third text, the fifth text, and the second label.

2. The model training method according to claim 1, characterized in that: The step of training the second model according to the first text, the second text, the first similarity, the third text, the fifth text, and the second label includes: Inputting the first text and the second text into the second model to obtain a third feature vector of the first text and a fourth feature vector of the second text; Normalizing the third eigenvector and the fourth eigenvector to obtain a first predicted label; Calculate a first loss value according to the first predicted label and the first similarity; Calculate a second loss value according to the third eigenvector, the fourth eigenvector, the first eigenvector, and the second eigenvector; The second model is trained according to the first loss value and the second loss value.

3. The model training method according to claim 1, characterized in that: The step of training the second model according to the first text, the second text, the first similarity, the third text, the fifth text, and the second label includes: Inputting the third text and the fifth text into the first model to obtain a fifth feature vector of the third text and a sixth feature vector of the fifth text; Inputting the third text and the fifth text into the second model to obtain a seventh feature vector of the third text and an eighth feature vector of the fifth text; Normalizing the seventh eigenvector and the eighth eigenvector to obtain a second predicted label; Calculate a third loss value according to the second predicted label and the second label; Calculate a fourth loss value according to the fifth eigenvector, the sixth eigenvector, the seventh eigenvector, and the eighth eigenvector; The second model is trained according to the third loss value and the fourth loss value.

4. The model training method according to claim 1, characterized in that: The first tag is used to indicate that the second text is an information recommendation text of the first text; and the second tag is used to indicate that the fifth text is not an information recommendation text of the third text.

5. The model training method according to claim 1, characterized in that: After the first label of the first positive sample is updated to the first similarity to obtain a second positive sample, the method further includes: The second text is subjected to noise processing to obtain a noisy second text.

6. An information recommendation method, characterized in that: include: An eighth text is obtained according to the sixth text, a seventh text corresponding to the sixth text, and a second model, wherein the second model is trained according to the model training method according to any one of claims 1-5.

7. A model training device, characterized in that: The model training device module: A first processing module is configured to determine a first positive sample and a first negative sample, wherein the first positive sample includes: a first text, a second text corresponding to the first text, and a first label; A second processing module is configured to input the first text and the second text into a first model as a first feature vector to obtain a first feature vector of the first text and a second feature vector of the second text, wherein the first model is trained according to the first positive sample and the first negative sample; A third processing module is configured to calculate the similarity between the first feature vector and the second feature vector to obtain a first similarity; A fourth processing module is configured to update the first label of the first positive sample to the first similarity to obtain a second positive sample, where the second positive sample includes the first text, the second text, and the first similarity; a fifth processing module, configured to calculate a second similarity between the third text and the fourth text, and determine a fifth text from the fourth text according to the second similarity to obtain a second negative sample, wherein the second negative sample includes the third text, the fifth text and a second label; The sixth processing module is configured to train a second model based on the first text, the second text, the first similarity, the third text, the fifth text and the second label.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the model training method described in any one of claims 1 to 5 are implemented.

9. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the model training method according to any one of claims 1 to 5.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the model training method described in any one of claims 1 to 5 are implemented.

Citation Information

Cited By

  • Abnormal driving state sample extraction method and device

    CN121188487A

  • Text similarity calculation method and system based on multi-algorithm fusion

    CN121279321A