Feature extraction model training method, device, equipment, medium and program product
By selecting and using historical versions of feature extraction models based on sample similarity in feature extraction model training, the problem of large differences between training sample labels and prediction results is solved, the training efficiency and accuracy of the model are improved, and more efficient features are achieved extract.
Patent Information
- Application Number
- CN202210208643.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-04
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2042-03-04
AI Technical Summary
In the prior art, during the training process, the model learning accuracy is reduced due to the existence of training samples with large differences between sample labels and prediction results. It is difficult to effectively pay attention to these samples when using full training samples, which reduces the model training efficiency and Effect.
By using the historical version of the feature extraction model to feature extraction on the training samples, determine the sample similarity, and select training sample pairs (the same label or sample pair with the largest/minimum similarity) that meet the specific relationship to train them, and update the target feature extraction. Model.
Improve the training efficiency and accuracy of feature extraction models, effectively distinguish samples with small sample similarity under the same label and large sample similarity under different labels, reduce the iteration time, and use the advantages of multiple historical versions to assist in training, further Improved model accuracy.
Smart Images

Figure CN114580533B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a training method, apparatus, device, storage medium and computer program product for a feature extraction model. Background Art
[0002] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0003] Artificial intelligence has been increasingly applied to feature extraction. In related technologies, the existing full training samples are usually used to iterate the feature extraction model multiple times to obtain a trained feature extraction model. However, during the training process, the predicted results of some training samples are very different from the sample labels. Such training samples will lead to reduced accuracy of model learning. If the full training samples are used in each iteration in related technologies, it is difficult to pay attention to such training samples, which not only reduces the efficiency of model training, but also makes the model learning effect poor. Summary of the invention
[0004] The embodiments of the present application provide a method, apparatus, device, storage medium and computer program product for training a feature extraction model, which can improve the training efficiency of the feature extraction model and improve the feature extraction accuracy of the trained feature extraction model.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] The present application provides a method for training a feature extraction model, including:
[0007] At least one historical version feature extraction model obtained through training is used to extract features from multiple training samples carrying sample labels to obtain multiple sample features corresponding to each of the historical versions;
[0008] Determining the sample similarity between any two of the training samples based on a plurality of sample features corresponding to each of the historical versions;
[0009] Based on the determined sample similarity, selecting at least one training sample pair from the plurality of training samples, the training sample pair comprising a first training sample and a second training sample;
[0010] The first training sample and the second training sample satisfy at least one of the following relationships:
[0011] The training sample with the same sample label and the smallest sample similarity with the first training sample among the multiple training samples is the second training sample; the training sample with different sample labels and the largest sample similarity with the first training sample among the multiple training samples is the second training sample;
[0012] Based on the selected at least one training sample pair, the target feature extraction model is trained to obtain a trained feature extraction model.
[0013] The present application also provides a training device for a feature extraction model, including:
[0014] A feature extraction module, configured to extract features from a plurality of training samples carrying sample labels using a feature extraction model of at least one historical version obtained through training, and obtain a plurality of sample features corresponding to each of the historical versions;
[0015] A determination module, used to determine the sample similarity between any two of the training samples based on a plurality of sample features corresponding to each of the historical versions;
[0016] A selection module, configured to select at least one training sample pair from the plurality of training samples based on the determined sample similarity, the training sample pair comprising a first training sample and a second training sample;
[0017] The first training sample and the second training sample satisfy at least one of the following relationships:
[0018] The training sample with the same sample label and the smallest sample similarity with the first training sample among the multiple training samples is the second training sample; the training sample with different sample labels and the largest sample similarity with the first training sample among the multiple training samples is the second training sample;
[0019] The training module is used to train the target feature extraction model based on the selected at least one training sample pair to obtain a trained feature extraction model.
[0020] In the above scheme, the determination module is also used to determine the feature similarity between any two sample features corresponding to each of the historical versions; based on the feature similarity between any two sample features corresponding to each of the historical versions, the sample similarity between the training samples corresponding to the any two sample features is determined to determine the sample similarity between any two of the training samples.
[0021] In the above scheme, when the number of historical versions is at least two, the determination module is also used to obtain the weight value corresponding to each of the historical versions; based on the weight value corresponding to each of the historical versions, the feature similarity between any two sample features corresponding to each of the historical versions is weighted averaged to obtain the sample similarity between the training samples corresponding to the any two sample features.
[0022] In the above scheme, the determination module is also used to obtain the feature similarity matrix corresponding to each of the historical versions, the (i, j)th matrix element in the feature similarity matrix being the feature similarity between the i-th sample feature and the j-th sample feature corresponding to the corresponding historical version; based on the feature similarity matrix corresponding to each of the historical versions, the sample similarity matrix corresponding to the multiple training samples is determined; the (i, j)th matrix element in the sample similarity matrix is used as the sample similarity between the i-th training sample and the j-th training sample in the multiple training samples to determine the sample similarity between any two of the training samples; wherein, i and j are both integers greater than zero and not exceeding m, and m is the number of the training samples.
[0023] In the above scheme, the determination module is also used to perform the following processing for each of the historical versions: for the i-th sample feature and the j-th sample feature corresponding to the historical version, determine the feature similarity between the i-th sample feature and the j-th sample feature, and use the feature similarity as the (i, j)-th matrix element in the feature similarity matrix to obtain the feature similarity matrix corresponding to the historical version.
[0024] In the above scheme, when the number of historical versions is at least two, the determination module is also used to obtain the weight value corresponding to each of the historical versions; based on the weight value corresponding to each of the historical versions, at least two of the feature similarity matrices are weighted averaged to obtain a sample similarity matrix corresponding to multiple training samples.
[0025] In the above scheme, the determination module is also used to obtain the index value of the model evaluation index corresponding to the feature extraction model of each historical version; based on the index value corresponding to the feature extraction model of each historical version, determine the weight value corresponding to the corresponding historical version.
[0026] In the above scheme, the selection module is also used to obtain each training sample pair by performing the following processing: selecting a training sample from the multiple training samples as the first training sample; determining the training sample whose sample label is the same as the sample label of the first training sample as the positive training sample, and determining the training sample whose sample label is different from the sample label of the first training sample as the negative training sample; selecting a target training sample from the positive training samples and the negative training samples as the second training sample; wherein the target training sample is at least one of the following training samples: the positive training sample with the smallest sample similarity with the first training sample among the positive training samples; and the negative training sample with the greatest sample similarity with the first training sample among the negative training samples.
[0027] In the above scheme, the training module is also used to perform feature extraction on each training sample in the at least one training sample pair through the target feature extraction model to obtain corresponding predicted sample features; obtain the difference between each predicted sample feature and the sample label of the corresponding training sample; based on the difference, update the model parameters of the target feature extraction model to obtain a trained feature extraction model.
[0028] In the above scheme, the second training sample includes: a positive training sample with the same sample label and the smallest sample similarity with the first training sample among the multiple training samples; and a negative training sample with different sample labels and the largest sample similarity with the first training sample among the multiple training samples; the training module is also used to extract the first prediction sample feature corresponding to the first training sample, the second prediction sample feature corresponding to the positive training sample, and the third prediction sample feature corresponding to the negative training sample through the target feature extraction model; determine the first feature similarity between the first prediction sample feature and the second prediction sample feature, and determine the second feature similarity between the first prediction sample feature and the third prediction sample feature; obtain a similarity interval parameter, and construct a loss function of the target feature extraction model based on the first feature similarity, the second feature similarity, and the similarity interval parameter; update the model parameters of the target feature extraction model based on the loss function to obtain a trained feature extraction model.
[0029] In the above scheme, the training module is also used to determine the feature extraction model corresponding to the latest historical version from the feature extraction model of at least one historical version, and determine the feature extraction model corresponding to the latest historical version as the target feature extraction model.
[0030] In the above scheme, the device also includes: a recommendation module; the recommendation module is used to respond to an acquisition request for recommended media information, and based on the trained feature extraction model, respectively extract first media information features of multiple media information to be recommended and second media information features of historical recommended media information; determine the feature similarity between each of the first media information features and the second media information features; based on the determined feature similarity, screen out target recommended media information that matches the acquisition request from multiple media information to be recommended, and return the target recommended media information.
[0031] The present application also provides an electronic device, including:
[0032] A memory for storing executable instructions;
[0033] The processor is used to implement the training method of the feature extraction model provided in the embodiment of the present application when executing the executable instructions stored in the memory.
[0034] An embodiment of the present application also provides a computer-readable storage medium storing executable instructions, which, when executed by a processor, implements the training method of the feature extraction model provided in the embodiment of the present application.
[0035] An embodiment of the present application also provides a computer program product, including a computer program or executable instructions, which, when executed by a processor, implements the training method of the feature extraction model provided in the embodiment of the present application.
[0036] The embodiments of the present application have the following beneficial effects:
[0037] First, feature extraction models of at least one historical version obtained through training are used to extract features from multiple training samples carrying sample labels to obtain multiple sample features corresponding to each historical version; then, based on the multiple sample features corresponding to each historical version, the sample similarity between any two training samples is determined; based on the determined sample similarity, at least one training sample pair is selected from the multiple training samples; and then, based on the selected at least one training sample pair, the target feature extraction model is trained to obtain a trained feature extraction model.
[0038] The training sample pair includes a first training sample and a second training sample, and the first training sample and the second training sample satisfy at least one of the following relationships: the sample labels are the same, and among multiple training samples, the training sample with the smallest sample similarity to the first training sample is the second training sample; the sample labels are different, and among multiple training samples, the training sample with the largest sample similarity to the first training sample is the second training sample. In this way, 1) during the training process, two training samples with smaller sample similarity under the same sample label and two training samples with larger similarity under different sample labels can be effectively distinguished, thereby improving the feature extraction accuracy of the feature extraction model obtained through training; 2) by screening the training sample pairs, the time required for each iteration is reduced, thereby improving the training efficiency of the feature extraction model; 3) when there are multiple historical versions, the advantages of the feature extraction models of historical versions with different structures can also be used to assist the training of the target feature extraction model, thereby further improving the feature extraction accuracy of the feature extraction model obtained through training. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1A 1 is a schematic diagram of the architecture of a training system 100 for a feature extraction model provided in an embodiment of the present application;
[0040] Figure 1B This is a schematic diagram of an application scenario of a feature extraction model provided in an embodiment of the present application;
[0041] Figure 1C This is an example of an application scenario of the feature extraction model provided in the embodiment of the present application. Figure 2 ;
[0042] Figure 1D This is an example of an application scenario of the feature extraction model provided in the embodiment of the present application. Figure 3 ;
[0043] Figure 2 1 is a flow chart of a method for training a feature extraction model provided in an embodiment of the present application;
[0044] Figure 3 This is a flow chart of the training method of the feature extraction model provided in the embodiment of the present application. Figure 2 ;
[0045] Figure 4 This is a flow chart of the training method of the feature extraction model provided in the embodiment of the present application. Figure 3 ;
[0046] Figure 5 is a schematic diagram of the selection process of each training sample pair provided in an embodiment of the present application;
[0047] Figure 6This is a flow chart of the training method of the feature extraction model provided in the embodiment of the present application. Figure 4 ;
[0048] Figure 7 It is a structural diagram of a training system for a feature extraction model provided in an embodiment of the present application;
[0049] Figure 8 is a structural schematic diagram of a training device 600 for a feature extraction model provided in an embodiment of the present application;
[0050] Fig. 9 It is a structural diagram of an electronic device 500 for implementing a training method for a feature extraction model provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0052] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0053] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0055] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0056] 1) Client: an application running in the terminal to provide various services, such as news client and video client.
[0057] 2) In response, it is used to indicate the conditions or states on which the executed operations depend. When the dependent conditions or states are met, one or more operations executed may be in real time or have a set delay. Unless otherwise specified, there is no restriction on the order of execution of the multiple operations executed.
[0058] The embodiments of the present application provide a method, apparatus, device, storage medium and computer program product for training a feature extraction model, which can improve the training efficiency of the feature extraction model and improve the feature extraction accuracy of the trained feature extraction model.
[0059] The following describes the implementation scenario of the feature extraction model training method provided in the embodiment of the present application. Figure 1A , Figure 1A It is a schematic diagram of the architecture of the training system 100 for the feature extraction model provided in an embodiment of the present application. To support an exemplary application, the terminal 400 is connected to the server 200 via the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two, and wireless or wired links are used to realize data transmission.
[0060] The terminal 400 is used to send a training request for the target feature extraction model to the server 200 in response to a training instruction for the target feature extraction model;
[0061] The server 200 is configured to receive a training request for a target feature extraction model sent by the terminal 400; in response to the training request, perform feature extraction on multiple training samples carrying sample labels respectively through the feature extraction model of at least one historical version obtained through training, and obtain multiple sample features corresponding to each historical version; determine the sample similarity between any two training samples based on the multiple sample features corresponding to each historical version; select at least one training sample pair from the multiple training samples based on the determined sample similarity; train the target feature extraction model based on the selected at least one training sample pair, and obtain a trained feature extraction model; and return a training completion notification of the feature extraction model to the terminal 400;
[0062] Here, the training sample pair includes a first training sample and a second training sample; wherein the first training sample and the second training sample satisfy at least one of the following relationships: the sample labels are the same, and among multiple training samples, the training sample with the smallest sample similarity to the first training sample is the second training sample; the sample labels are different, and among multiple training samples, the training sample with the largest sample similarity to the first training sample is the second training sample;
[0063] Terminal 400 is used to receive a notification of the completion of training of a feature extraction model. Afterwards, terminal 400 may request server 200 to download the trained feature extraction model to perform feature extraction based on the trained feature extraction model; or terminal 400 may also send a task request to server 200 to perform a feature extraction task, so that server 200 responds to the task request and performs feature extraction based on the trained feature extraction model. For example, the task of video feature extraction for video, the task of image feature extraction for image, the task of text feature extraction for text, the task of audio feature extraction for audio, etc.
[0064] For some examples, see Figure 1B , Figure 1B This is a schematic diagram of an application scenario of the feature extraction model provided in an embodiment of the present application. Here, the terminal 400 (installed with a client, such as a media information client) sends a request to obtain recommended media information to the server 200; the server 200 receives the request to obtain, obtains multiple media information to be recommended, and the historical recommended media information of the user corresponding to the request; the server 200 extracts the first media information features of multiple media information to be recommended and the second media information features of the historical recommended media information based on the trained feature extraction model; the server 200 determines the feature similarity between each first media information feature and the second media information feature, and based on the determined feature similarity, selects the target recommended media information that matches the request from the multiple media information to be recommended, and returns the target recommended media information to the terminal 400; the terminal 400 receives and displays the target recommended media information. In this way, the recommendation of media information is realized. In actual applications, the media information includes text information (such as news), picture information, video, and audio information (such as music, audio books, etc.).
[0065] For some examples, see Figure 1C , Figure 1C This is an example of an application scenario of the feature extraction model provided in the embodiment of the present application. Figure 2. Here, the terminal 400 (installed with a client, such as a video client) sends a search request for a target video to the server 200, and the search request carries a reference video for searching the video; the server 200 receives the search request for the target video, extracts the first video feature of the reference video and the second video feature of multiple candidate videos based on the trained feature extraction model, and determines the feature similarity between each second video feature and the first video feature; based on the determined feature similarity, the server 200 selects a target candidate video whose feature similarity with the first video feature reaches a similarity threshold from multiple candidate videos, and returns the target candidate video as the target video to the terminal 400; the terminal 400 receives and displays the target video. In this way, the effect of searching for a video (target video) based on a video (reference video) is achieved.
[0066] For some examples, see Figure 1D , Figure 1D This is an example of an application scenario of the feature extraction model provided in the embodiment of the present application. Figure 3 . Here, the terminal 400 (installed with a client, such as a pronunciation practice client) receives the audio information input for the target content (such as English words, TV drama lines, etc.) and sends it to the server 200; the server 200 receives the audio information and obtains the standard audio information corresponding to the target content; the server 200 extracts the first audio feature of the audio information and the second audio feature of the standard audio information through the trained feature extraction model, and determines the feature similarity between the first audio feature and the second audio feature; the server 200 scores the audio information based on the determined feature similarity, obtains the corresponding audio score and returns it to the terminal 400; the terminal 400 receives and displays the audio score of the audio information. In this way, the effect of pronunciation practice scoring is achieved.
[0067] In some embodiments, the training method of the feature extraction model provided in the embodiment of the present application can be implemented by various electronic devices, for example, it can be implemented by a terminal alone, it can be implemented by a server alone, or it can be implemented by a terminal and a server in collaboration. For example, the terminal alone executes the training method of the feature extraction model provided in the embodiment of the present application, or the terminal sends a training request for a target feature extraction model to the server, and the server executes the training method of the feature extraction model provided in the embodiment of the present application according to the received training request. The embodiment of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.
[0068] In some embodiments, the electronic device for implementing the training of the feature extraction model provided in the embodiments of the present application may be various types of terminals or servers. Among them, the server (e.g., server 200) may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms. The terminal (e.g., terminal 400) may be a smart phone, a tablet computer, a laptop computer, a desktop computer, an intelligent voice interaction device (e.g., an intelligent speaker), a smart home appliance (e.g., a smart TV), a smart watch, a car terminal, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected by wired or wireless communication, and the embodiments of the present application do not limit this.
[0069] In some embodiments, the terminal or server can implement the training method of the feature extraction model provided in the embodiment of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a native application (APP, Application), that is, a program that needs to be installed in the operating system to run; it can also be a small program, that is, a program that can be run only by downloading it to a browser environment; it can also be a small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0070] In some embodiments, multiple servers may form a blockchain, and the servers are nodes on the blockchain. Information connections may exist between each node in the blockchain, and information may be transmitted between nodes through the above information connections. Among them, data related to the training method of the feature extraction model provided in the embodiment of the present application (such as feature extraction models of historical versions, multiple training samples and sample labels carried by them, feature extraction models that have been trained, etc.) may be stored on the blockchain.
[0071] The following describes the training method of the feature extraction model provided in the embodiment of the present application. In some embodiments, the training method of the feature extraction model provided in the embodiment of the present application can be implemented by various electronic devices, for example, it can be implemented by a terminal alone, it can also be implemented by a server alone, or it can be implemented by a terminal and a server in collaboration. Taking the server implementation as an example, see Figure 2 , Figure 2 1 is a flow chart of a method for training a feature extraction model provided in an embodiment of the present application. The method for training a feature extraction model provided in an embodiment of the present application includes:
[0072] Step 101: The server uses at least one historical version feature extraction model obtained through training to perform feature extraction on multiple training samples carrying sample labels to obtain multiple sample features corresponding to each historical version.
[0073] In an embodiment of the present application, the server trains the target feature extraction model to obtain a trained feature extraction model, and the trained feature extraction model can be used to perform feature extraction tasks, such as video feature extraction tasks, text feature extraction tasks, image feature extraction tasks, audio feature extraction tasks, etc.
[0074] In practical applications, when the server needs to train the target feature extraction model, for example, when the server receives a training request for the target feature extraction model sent by the terminal, the server responds to the training request and obtains multiple training samples for training the target feature extraction model, and the training samples carry sample labels. Among them, multiple is used to represent two or more.
[0075] In an embodiment of the present application, when training the target feature extraction model, first obtain the feature extraction model of at least one historical version obtained through training. The feature extraction model of the historical version is obtained by training the initial feature extraction model in the historical training stage. The feature extraction models corresponding to different historical versions are different. For example, the model parameters between the feature extraction models of different historical versions may be different, and the model structures between the feature extraction models of different historical versions may also be different. After obtaining the feature extraction model of at least one historical version obtained through training, feature extraction is performed on multiple training samples respectively through the feature extraction model of at least one historical version obtained through training (that is, the training samples are predicted through the feature extraction model of the historical version), and the sample features corresponding to each historical version (that is, the prediction results corresponding to the feature extraction model of each historical version) are obtained.
[0076] For example, the multiple historical versions include version 1 and version 2, and the multiple training samples include sample 1, sample 2, and sample 3. Feature extraction is performed on the multiple training samples respectively through the feature extraction model of the historical version, that is, feature extraction is performed on sample 1, sample 2, and sample 3 respectively through the feature extraction model of version 1 to obtain multiple sample features corresponding to version 1 (including: feature 11 corresponding to sample 1, feature 12 corresponding to sample 2, and feature 13 corresponding to sample 3); feature extraction is performed on sample 1, sample 2, and sample 3 respectively through the feature extraction model of version 2 to obtain multiple sample features corresponding to version 2 (including: feature 21 corresponding to sample 1, feature 22 corresponding to sample 2, and feature 23 corresponding to sample 3).
[0077] Step 102: Based on multiple sample features corresponding to each historical version, determine the sample similarity between any two training samples.
[0078] In actual applications, after the server obtains multiple sample features corresponding to each historical version, the sample similarity between any two training samples is determined based on the multiple sample features corresponding to each historical version.
[0079] In some embodiments, the server may determine the sample similarity between any two training samples based on multiple sample features corresponding to each historical version in the following manner: determine the feature similarity between any two sample features corresponding to each historical version; based on the feature similarity between any two sample features corresponding to each historical version, determine the sample similarity between the training samples corresponding to any two sample features, so as to determine the sample similarity between any two training samples.
[0080] Since the sample features are obtained by extracting features from the corresponding training samples using the feature extraction model of the historical version, in practical applications, the sample similarity between the training samples corresponding to any two sample features can be determined by the feature similarity between any two sample features among the multiple sample features. Specifically, first, for each historical version, the server can determine the feature similarity between two sample features of the task among the multiple sample features corresponding to the historical version, so as to obtain the feature similarity between two sample features of the task among the multiple sample features corresponding to each historical version. Then, based on the feature similarity between any two sample features among the multiple sample features corresponding to each historical version, the server determines the sample similarity between the training samples corresponding to the any two sample features, thereby obtaining the sample similarity between any two training samples among the multiple training samples.
[0081] In some embodiments, when the number of historical versions is one, the server may determine the feature similarity between any two sample features among the multiple sample features corresponding to the historical version as the sample similarity between the training samples corresponding to the any two sample features. For example, if any two sample features among the multiple sample features corresponding to historical version 1 are feature A and feature B, then the feature similarity between feature A and feature B may be determined as the sample similarity between training sample 1 corresponding to feature A and training sample 2 corresponding to feature B.
[0082] In some embodiments, when the number of historical versions is at least two, based on the feature similarity between any two sample features corresponding to each historical version, the server can determine the sample similarity between the training samples corresponding to any two sample features in the following manner: obtain the weight value corresponding to each historical version; based on the weight value corresponding to each historical version, perform weighted average processing on the feature similarity between any two sample features corresponding to each historical version to obtain the sample similarity between the training samples corresponding to any two sample features. In actual implementation, the weight value corresponding to each historical version can be determined by the index value of the model evaluation index (such as the accuracy rate, recall rate, actual use effect parameters after going online, etc.) of the feature extraction model based on the corresponding historical version.
[0083] In actual implementation, when determining the feature similarity between any two sample features among the plurality of sample features, the cosine similarity between any two sample features may be determined, for example, calculated by using a cosine similarity function.
[0084] For example, by using the feature extraction model of historical version 1, feature extraction is performed on training sample 1 and training sample 2 respectively, and multiple sample features corresponding to historical version 1 are obtained, including: sample feature A1 corresponding to training sample 1, and sample feature B1 corresponding to training sample 2; by using the feature extraction model of historical version 2, feature extraction is performed on training sample 1 and training sample 2 respectively, and multiple sample features corresponding to historical version 2 are obtained, including: sample feature A2 corresponding to training sample 1, and sample feature B2 corresponding to training sample 2. Among them, the feature similarity between sample feature A1 and sample feature B1 corresponding to historical version 1 is D1, and the feature similarity between sample feature A2 and sample feature B2 corresponding to historical version 2 is D2. The weight value corresponding to historical version 1 is x, and the weight value corresponding to historical version 2 is y. Then, based on the weight value corresponding to each historical version, the feature similarity between any two sample features corresponding to each historical version is weighted averaged, and the sample similarity between the training samples corresponding to any two sample features can be obtained: (x*D1+y*D2) / (x+y)=M, where M is the sample similarity between training sample 1 and training sample 2.
[0085] See also Figure 3 , Figure 3 This is a flow chart of the training method of the feature extraction model provided in the embodiment of the present application. Figure 2, including: Step 201: Determine the feature similarity between any two sample features corresponding to each historical version. Step 202: Determine whether the number of historical versions is greater than 1, if not, execute step 203, if not, execute step 204. Step 203: When the number of historical versions is one, determine the feature similarity between any two sample features corresponding to the historical version as the sample similarity between the training samples corresponding to any two sample features. Step 204: When the number of historical versions is at least two, obtain the weight value corresponding to each historical version. Step 205: Based on the weight value corresponding to each historical version, perform weighted averaging on the feature similarity between any two sample features corresponding to each historical version to obtain the sample similarity between the training samples corresponding to any two sample features.
[0086] In some embodiments, the server can determine the sample similarity between any two training samples based on multiple sample features corresponding to each historical version in the following manner: obtain a feature similarity matrix corresponding to each historical version, the (i, j)th matrix element in the feature similarity matrix being the feature similarity between the i-th sample feature and the j-th sample feature corresponding to the corresponding historical version; determine a sample similarity matrix corresponding to multiple training samples based on the feature similarity matrix corresponding to each historical version; use the (i, j)th matrix element in the sample similarity matrix as the sample similarity between the i-th training sample and the j-th training sample in multiple training samples to determine the sample similarity between any two training samples; wherein i and j are both integers greater than zero and not exceeding m, and m is the number of training samples.
[0087] In practical applications, the sample similarity between any two training samples in a plurality of training samples can also be determined by means of a similarity matrix. First, the server obtains the feature similarity matrix corresponding to each historical version, wherein the (i, j)th matrix element in the feature similarity matrix is the feature similarity between the i-th sample feature and the j-th sample feature corresponding to the corresponding historical version. In some embodiments, the server can obtain the feature similarity matrix corresponding to each historical version in the following manner: for each historical version, the following processing is performed respectively: for the i-th sample feature and the j-th sample feature corresponding to the historical version, the feature similarity between the i-th sample feature and the j-th sample feature is determined, and the feature similarity is used as the (i, j)th matrix element in the feature similarity matrix to obtain the feature similarity matrix corresponding to the historical version. In actual implementation, the feature similarity between the i-th sample feature and the j-th sample feature can be the cosine similarity between the i-th sample feature and the j-th sample feature calculated by the cosine similarity function.
[0088] After obtaining the feature similarity matrix corresponding to each historical version, the server determines the sample similarity matrix corresponding to multiple training samples based on the feature similarity matrix corresponding to each historical version, so that the (i, j)th matrix element in the sample similarity matrix can be used as the sample similarity between the i-th training sample and the j-th training sample in the multiple training samples. In this way, the sample similarity between any two training samples in the multiple training samples is obtained.
[0089] In some embodiments, when the number of historical versions is one, the server may determine the feature similarity matrix corresponding to the historical version as a sample similarity matrix corresponding to multiple training samples.
[0090] In some embodiments, when the number of historical versions is at least two, the server can determine the sample similarity matrices corresponding to the multiple training samples based on the feature similarity matrices corresponding to the historical versions in the following manner: obtain the weight value corresponding to each historical version; based on the weight value corresponding to each historical version, perform weighted average processing on at least two feature similarity matrices to obtain the sample similarity matrices corresponding to the multiple training samples. In actual implementation, the weight value corresponding to each historical version can be determined by the index value of the model evaluation index (such as the accuracy rate, recall rate, actual use effect after going online, etc.) of the feature extraction model based on the corresponding historical version.
[0091] For example, the weight value corresponding to historical version 1 is a, and the feature similarity matrix is S1; the weight value corresponding to historical version 2 is b, and the feature similarity matrix is S2; the weight value corresponding to historical version 3 is c, and the feature similarity matrix is S3; then based on the weight values corresponding to each historical version, at least two feature similarity matrices are weighted averaged to obtain the sample similarity matrix S = (a*S1+b*S2+c*S3) / (a+b+c) corresponding to multiple training samples.
[0092] See also Figure 4 , Figure 4 This is a flow chart of the training method of the feature extraction model provided in the embodiment of the present application. Figure 3, including: Step 301: for each historical version, respectively perform the following processing: Step 3011: for the i-th sample feature and the j-th sample feature corresponding to the historical version, determine the feature similarity between the i-th sample feature and the j-th sample feature; Step 3012: use the feature similarity as the (i, j)-th matrix element in the feature similarity matrix to obtain the feature similarity matrix corresponding to the historical version. Step 302: determine whether the number of historical versions is greater than 1, if not, execute step 303, if not, execute step 304. Step 303: when the number of historical versions is one, determine the feature similarity matrix corresponding to the historical version as the sample similarity matrix corresponding to multiple training samples. Step 304: when the number of historical versions is at least two, obtain the weight value corresponding to each historical version. Step 305: based on the weight value corresponding to each historical version, perform weighted average processing on at least two feature similarity matrices to obtain the sample similarity matrix corresponding to multiple training samples. Step 306: The (i, j)th matrix element in the sample similarity matrix is used as the sample similarity between the i-th training sample and the j-th training sample in the multiple training samples to determine the sample similarity between any two training samples, where i and j are both integers greater than zero and not greater than m, and m is the number of training samples.
[0093] In some embodiments, the server can obtain the weight value corresponding to each historical version in the following manner: obtain the index value of the model evaluation index corresponding to the feature extraction model of each historical version; based on the index value corresponding to the feature extraction model of each historical version, determine the weight value corresponding to the corresponding historical version.
[0094] In actual applications, the server can obtain the index values of the model evaluation indicators corresponding to the feature extraction models of each historical version. The model evaluation indicators may include the accuracy, recall rate, and actual use effect parameters after going online of the model, and then determine the weight value corresponding to the corresponding historical version based on the index values corresponding to the feature extraction models of each historical version. Specifically, the index value of one of the multiple model evaluation indicators can be determined as the weight value corresponding to the historical version; the index values of the multiple model evaluation indicators can also be weighted averaged, and the result of the processing is used as the weight value corresponding to the historical version.
[0095] Step 103: Based on the determined sample similarity, at least one training sample pair is selected from the plurality of training samples, where the training sample pair includes a first training sample and a second training sample.
[0096] Here, after determining the sample similarity between any two training samples from the multiple training samples, the server selects at least one training sample pair from the multiple training samples based on the determined sample similarity, and the training sample pair includes a first training sample and a second training sample. The first training sample and the second training sample satisfy at least one of the following relationships: the training sample with the same sample label and the smallest sample similarity with the first training sample among the multiple training samples is the second training sample; the training sample with different sample labels and the largest sample similarity with the first training sample among the multiple training samples is the second training sample.
[0097] In some embodiments, the server may select at least one training sample pair from multiple training samples based on the determined sample similarity in the following manner: each training sample pair is obtained by performing the following processing: selecting a training sample from multiple training samples as the first training sample; determining that a training sample whose sample label is the same as the sample label of the first training sample is a positive training sample, and determining that a training sample whose sample label is different from the sample label of the first training sample is a negative training sample; selecting a target training sample from the positive training samples and the negative training samples as the second training sample; wherein the target training sample is at least one of the following training samples: among the positive training samples, the positive training sample with the smallest sample similarity to the first training sample; and among the negative training samples, the negative training sample with the greatest sample similarity to the first training sample.
[0098] Here, the number of training sample pairs can be one or more. The server can select each training sample pair from multiple training samples in the following manner: first, randomly select a training sample from multiple training samples as the first training sample. It should be noted that each randomly selected training sample is different from the first training sample and the second training sample in the determined training sample pair; then, based on the sample labels of each training sample, determine that the training sample whose sample label is the same as the sample label of the first training sample is a positive training sample, and determine that the training sample whose sample label is different from the sample label of the first training sample is a negative training sample; finally, select a target training sample from the positive training samples and the negative training samples as the second training sample. It should be noted that the target training sample is at least one of the following training samples: among the positive training samples, the positive training sample with the smallest sample similarity to the first training sample; among the negative training samples, the negative training sample with the largest sample similarity to the first training sample. In this way, the second training sample is at least one of the positive training sample with the smallest sample similarity to the first training sample and the negative training sample with the largest sample similarity to the first training sample, which can increase the difficulty of model training and thus make the prediction ability of the trained model more accurate.
[0099] See also Figure 5 , Figure 5It is a schematic diagram of the selection process of each training sample pair provided by the embodiment of the present application, including: step 401: select a training sample from multiple training samples as the first training sample in the training sample pair; step 402: determine that the training sample whose sample label is the same as the sample label of the first training sample is a positive training sample; step 403: determine that the training sample whose sample label is different from the sample label of the first training sample is a negative training sample; step 404: select the positive training sample with the smallest sample similarity with the first training sample from the positive training samples as the second training sample in the training sample pair; step 405: select the negative training sample with the largest sample similarity with the first training sample from the negative training samples as the second training sample in the training sample pair. In this way, a training sample pair consisting of the first training sample, the positive training sample with the smallest sample similarity with the first training sample in the positive training samples, and the negative training sample with the largest sample similarity with the first training sample in the negative training samples is obtained.
[0100] Step 104: Based on the selected at least one training sample pair, the target feature extraction model is trained to obtain a trained feature extraction model.
[0101] In actual applications, after the server selects at least one training sample pair, it trains the target feature extraction model based on the selected at least one training sample pair to obtain a trained feature extraction model. In some embodiments, the target feature extraction model may be a feature extraction model corresponding to the latest historical version in the feature extraction model of at least one historical version. For example, the server may determine the feature extraction model corresponding to the latest historical version from the feature extraction model of at least one historical version, and determine the feature extraction model corresponding to the latest historical version as the target feature extraction model. In other embodiments, the target feature extraction model may also be a feature extraction model newly constructed based on a neural network (such as a convolutional neural network, a deep neural network, etc.) and different from the historical version.
[0102] It should be noted that the trained feature extraction model obtained after training the target feature extraction model can be used as the latest version of the feature extraction model for feature extraction processing. The latest version of the feature extraction model is different from at least one historical version of the feature extraction model mentioned above.
[0103] In some embodiments, the server may train the target feature extraction model based on at least one selected training sample pair to obtain a trained feature extraction model in the following manner: perform feature extraction on each training sample in at least one training sample pair through the target feature extraction model to obtain corresponding predicted sample features; obtain the difference between each predicted sample feature and the sample label of the corresponding training sample; based on the difference, update the model parameters of the target feature extraction model to obtain a trained feature extraction model.
[0104] In practical applications, when the server trains the target feature extraction model based on at least one selected training sample pair, first, the server extracts features from each training sample in the at least one training sample pair through the target feature extraction model to obtain corresponding predicted sample features; then, the difference between each predicted sample feature and the sample label of the corresponding training sample is obtained, and then based on the difference, the model parameters of the target feature extraction model are updated to obtain a trained feature extraction model. Specifically, the server can update the model parameters of the target feature extraction model based on the difference in the following manner: based on the difference, determine the value of the loss function of the target feature extraction model; when the value of the loss function exceeds the loss threshold, determine the error signal of the target feature extraction model based on the value of the loss function; back-propagate the error signal in the target feature extraction model, and update the model parameters of the target feature extraction model during the propagation process.
[0105] In some embodiments, the second training sample includes: a positive training sample with the same sample label and the smallest sample similarity with the first training sample among multiple training samples; and a negative training sample with different sample labels and the largest sample similarity with the first training sample among multiple training samples; accordingly, the server can train the target feature extraction model based on at least one selected training sample pair in the following manner to obtain a trained feature extraction model: extract the first prediction sample feature corresponding to the first training sample, the second prediction sample feature corresponding to the positive training sample, and the third prediction sample feature corresponding to the negative training sample through the target feature extraction model; determine the first feature similarity between the first prediction sample feature and the second prediction sample feature, and determine the second feature similarity between the first prediction sample feature and the third prediction sample feature; obtain a similarity interval parameter, and construct a loss function of the target feature extraction model based on the first feature similarity, the second feature similarity, and the similarity interval parameter; update the model parameters of the target feature extraction model based on the loss function to obtain a trained feature extraction model.
[0106] Here, the second training sample includes: a positive training sample with the same sample label and the smallest sample similarity with the first training sample among multiple training samples; and a negative training sample with different sample labels and the largest sample similarity with the first training sample among multiple training samples. When the server trains the target feature extraction model based on the selected at least one training sample pair, first, the server extracts features from the first training sample through the target feature extraction model to obtain a first prediction sample feature, extracts features from the positive training sample through the target feature extraction model to obtain a second prediction sample feature, and extracts features from the negative training sample through the target feature extraction model to obtain a third prediction sample feature;
[0107] Then, the first feature similarity between the first prediction sample feature and the second prediction sample feature is determined, and the second feature similarity between the first prediction sample feature and the third prediction sample feature is determined. Then, a similarity interval parameter is obtained, so as to construct a loss function of the target feature extraction model based on the first feature similarity, the second feature similarity, and the similarity interval parameter; finally, the model parameters of the target feature extraction model are updated based on the loss function to obtain a trained feature extraction model.
[0108] In practical applications, the loss function of the constructed target feature extraction model can be described by the following formula:
[0109]
[0110] in, is the value of the loss function, is the first predicted sample feature corresponding to the first training sample extracted by the target feature extraction model K, is the second predicted sample feature corresponding to the positive training sample extracted by the target feature extraction model K, is the third predicted sample feature corresponding to the negative training sample extracted by the target feature extraction model K, is the first feature similarity, is the second feature similarity, γ is the similarity interval parameter, and max() is the maximum value function.
[0111] See also Figure 6 , Figure 6 This is a flow chart of the training method of the feature extraction model provided in the embodiment of the present application. Figure 4, including: step 501: extracting the first prediction sample feature corresponding to the first training sample, the second prediction sample feature corresponding to the positive training sample, and the third prediction sample feature corresponding to the negative training sample through the target feature extraction model; step 502: determining the first feature similarity between the first prediction sample feature and the second prediction sample feature, and determining the second feature similarity between the first prediction sample feature and the third prediction sample feature; step 503: obtaining a similarity interval parameter; step 504: constructing a loss function of the target feature extraction model based on the first feature similarity, the second feature similarity, and the similarity interval parameter; step 505: updating the model parameters of the target feature extraction model based on the loss function to obtain a trained feature extraction model.
[0112] In some embodiments, the trained feature extraction model can be applied to media information recommendation scenarios: in response to a request to obtain recommended media information, based on the trained feature extraction model, first media information features of multiple media information to be recommended and second media information features of historically recommended media information are extracted respectively; the feature similarity between each first media information feature and the second media information feature is determined; based on the determined feature similarity, target recommended media information that matches the acquisition request is screened from multiple media information to be recommended, and the target recommended media information is returned.
[0113] In actual applications, the recommended media information includes text information (such as news), picture information, video information, and audio information (such as music, audio books, etc.). The terminal can send a request to the server to obtain the recommended media information. The server receives and responds to the request to obtain the recommended media information, and obtains multiple media information to be recommended, as well as the historical recommended media information of the user corresponding to the acquisition request. Then, based on the trained feature extraction model, the first media information features of the multiple media information to be recommended and the second media information features of the historical recommended media information are extracted respectively, so as to determine the feature similarity between each first media information feature and the second media information feature, so as to screen the target recommended media information that matches the acquisition request from the multiple media information to be recommended based on the determined feature similarity, and return the target recommended media information to the terminal.
[0114] In actual implementation, the target recommended media information selected for different recommendation scenarios may be different. For example, in order to avoid repeated recommendations, the to-be-recommended media information whose feature similarity with the second media information feature is lower than the first similarity threshold may be selected as the target recommended media information; for another example, in order to make the recommended media information more in line with the needs of the user, the to-be-recommended media information whose feature similarity with the second media information feature is higher than the second similarity threshold may be selected as the target recommended media information. The first similarity threshold and the second similarity threshold have no specific association, and may be pre-set, the same or different.
[0115] By applying the above-mentioned embodiments of the present application, first, a feature extraction model of at least one historical version obtained through training is used to perform feature extraction on multiple training samples carrying sample labels, respectively, to obtain multiple sample features corresponding to each historical version; then, based on the multiple sample features corresponding to each historical version, the sample similarity between any two training samples is determined; then, based on the determined sample similarity, at least one training sample pair is selected from the multiple training samples; thus, based on the selected at least one training sample pair, the target feature extraction model is trained to obtain a trained feature extraction model.
[0116] The training sample pair includes a first training sample and a second training sample, and the first training sample and the second training sample satisfy at least one of the following relationships: the sample labels are the same, and among multiple training samples, the training sample with the smallest sample similarity to the first training sample is the second training sample; the sample labels are different, and among multiple training samples, the training sample with the largest sample similarity to the first training sample is the second training sample. In this way, 1) during the training process, two training samples with smaller sample similarity under the same sample label and two training samples with larger similarity under different sample labels can be effectively distinguished, thereby improving the feature extraction accuracy of the feature extraction model obtained through training; 2) by screening the training sample pairs, the time required for each iteration is reduced, thereby improving the training efficiency of the feature extraction model; 3) when there are multiple historical versions, the advantages of the feature extraction models of historical versions with different structures can also be used to assist the training of the target feature extraction model, thereby further improving the feature extraction accuracy of the feature extraction model obtained through training.
[0117] The following will describe an exemplary application of the embodiment of the present application in an actual application scenario. Taking the feature extraction model as a video feature extraction model as an example, the training method of the feature extraction model provided by the embodiment of the present application will be described. First, the terms involved in the embodiment of the present application are explained, including:
[0118] 1) Video features, namely video embeddings, are vectorized feature descriptions of the semantic content of each video, also known as video embeddings. The distance between two video embeddings measures the semantic similarity between the two videos. The more similar the two videos are, the smaller the embedding distance between them. 2) Difficult samples: training samples whose prediction results have a large error with the true sample labels.
[0119] In some embodiments, 1) the purpose of training the current version model with the historical version model can be achieved through transfer learning, but the method based on transfer learning cannot fully utilize different model structures. 2) The purpose of training the current version model with the historical version model can be achieved through lifelong learning, but the method based on lifelong learning uses one model from beginning to end and cannot fully utilize different model structures. 3) The purpose of training the current version model with the historical version model can be achieved through ensemble learning, but the limitation of the method based on ensemble learning is that the prediction results of each base model need to be obtained in the prediction stage before the integrated output can be performed, which results in a relatively large time overhead and space required to store each model parameter.
[0120] In some embodiments, the mining of difficult samples includes: 1) online difficult sample mining, determining the detection box with a high loss function value as a difficult sample, but the limitation is that the structure of the model is usually fixed and cannot fully utilize different model structures. 2) by designing different loss functions, so that the model focuses on difficult samples during training, but the limitation is that the structure of the model is usually fixed and cannot fully utilize different model structures.
[0121] Based on this, the embodiment of the present application also provides a method for training a feature extraction model, which can perform a metric learning method for difficult sample mining based on multiple historical version models with different structures, for better learning video features. Specifically, firstly, each historical version model is used to extract the video features of the data set (i.e., multiple training samples), and the feature similarity matrix of the video features corresponding to each historical version is determined (the (i, j)th matrix element in the feature similarity matrix is the feature similarity between the i-th sample feature and the j-th sample feature corresponding to the corresponding historical version); then, the feature similarity matrix corresponding to each historical version is weighted averaged according to the model evaluation index of each historical version to obtain a sample similarity matrix (the (i, j)th matrix element in the sample similarity matrix is the sample similarity between the i-th sample feature and the j-th sample feature in multiple training samples); finally, according to the sample similarity matrix, combined with the sample labels of the training samples, difficult samples (i.e., the above-mentioned training sample pairs) are sampled, so as to perform metric learning on the feature extraction model based on the difficult samples.
[0122] Next, the training method of the feature extraction model provided in the embodiment of the present application is described in detail. Figure 7 , Figure 7 It is a structural diagram of the training system of the feature extraction model provided in the embodiment of the present application. Here, the training system of the feature extraction model provided in the embodiment of the present application is divided into two stages: training and prediction. Among them, the training stage needs to utilize the historical version model and the current version model (that is, the above-mentioned target feature extraction model), while the prediction stage only needs to utilize the trained current version model. Specifically, the training stage performs feature extraction on multiple training samples based on the historical version model to obtain the video features corresponding to each historical version, and calculates the feature similarity matrix of the video features corresponding to each historical version, and then performs weighted averaging on the feature similarity matrix corresponding to each historical version according to the model evaluation index of each historical version to obtain the sample similarity matrix, and performs difficult sample sampling according to the sample similarity matrix, and finally performs metric learning based on the difficult samples.
[0123] First, the training phase includes: (1) Historical version model feature extraction module. Let {v1,v2,...,v m} represents a data set (i.e., multiple training samples), which consists of m training samples (video samples), where v i represents the i-th (i is an integer greater than 0 and not more than m) video sample in the data set. In the embodiment of the present application, the feature extraction models of the historical version are (K-1) (K is an integer greater than 0), respectively represented by f1, f2,...,f (K -1) indicates.
[0124] The historical version model feature extraction module extracts video features of multiple training samples through (K-1) historical version models, that is, for the kth (k is an integer greater than 0 and not more than (K-1)) historical version model, extracts video sample v i The video feature is x i =f k (v i ). Thus, for the kth historical version model, the extracted video features are
[0125] (2) Similarity matrix calculation module. After using (K-1) historical version models to extract video features of multiple training samples respectively, the similarity matrix between any two video features is calculated. The feature similarity matrix of multiple video features corresponding to the kth historical version model is defined as The matrix element (i, j) in the feature similarity matrix is Wherein, j is an integer greater than 0 and not more than m), and d is a similarity measurement function. For example, the similarity measurement function may use a cosine similarity measurement function, as shown below:
[0126]
[0127] in, is the video feature x corresponding to the kth historical version model i and video features x j The feature similarity between is the video feature x corresponding to the kth historical version model i , is the video feature x corresponding to the kth historical version model j .
[0128] In this way, the feature similarity matrix S of (K-1) historical version models can be obtained through the above method: (1) , S (2) ···S (K-1) For each historical version model, there is a corresponding model evaluation index, so the index value a of the model evaluation index of (K-1) historical version models can be obtained. (1) 、a (2) ···a (K-1) , where the index value of the model evaluation index of the k-th historical version model is Therefore, based on the feature similarity matrices of (K-1) historical version models and the corresponding index values, the feature similarity matrices of (K-1) historical version models can be weighted averaged to obtain the weighted average similarity matrix as the sample similarity matrix, which is still an m×m matrix. Specifically, it can be calculated using the following formula:
[0129]
[0130] Among them, S is the sample similarity matrix, S k is the feature similarity matrix of the kth historical version model.
[0131] (3) Difficult sample sampling module. After the sample similarity matrix S, combined with the dataset {v1,v2,...,v m} and the sample labels (Label) of the dataset {y1,y2,...,y m},in For two videos v i and v j , if the corresponding mark y i =y j , then the two videos belong to the same category; otherwise, they belong to different categories.
[0132] When sampling difficult samples, randomly select a training sample as the anchor sample (i.e., the first training sample mentioned above), denoted as v a , and its corresponding sample label is y a , and then according to the sample labels of other training samples and the sample labels of the anchor sample, the positive sample set P and the negative sample set N are obtained through the following relationship formula:
[0133]
[0134] Then, according to the sample similarity matrix S obtained by the similarity matrix calculation module, the sample similarity between each training sample and the anchor sample in the positive sample set P and the negative sample set N is calculated respectively. Specifically, for any training sample v i , the training sample and the anchor sample v a The sample similarity S ai is the matrix element (a,i) in the sample similarity matrix S, where a is an integer greater than 0 and not more than m.
[0135] Finally, sample and v in the positive sample set P a The training sample with the lowest similarity is used as the positive sample v p , sample and v in the negative sample set N a The training sample with the highest similarity is used as the negative sample v n , the anchor sample v a , positive sample v p And negative samples v n Thus, compared with randomly sampling one sample in P and one sample in N as positive and negative samples, the embodiment of the present application increases the difficulty of training by finding the positive sample with the lowest similarity and the negative sample with the highest similarity, which can make the prediction ability of the trained model more accurate.
[0136] (4) Metric learning module. For the anchor sample v sampled by the difficult sample sampling module a , positive sample v p And negative samples v n , respectively, after the current version of the model to be trained f K , extract their video features and get and Then calculate the value of the metric loss function, which is shown in the following formula:
[0137]
[0138] Among them, γ is a hyperparameter, which represents the margin. The meaning of the measurement loss function is to make the similarity between the features of the anchor sample and the features of the positive sample exceed the similarity between the features of the anchor sample and the features of the negative sample by a certain interval γ. This makes the video features of samples of the same type as close as possible and the video features of samples of different types as far apart as possible, so as to improve the training accuracy of the feature extraction model.
[0139] In practical applications, the training of the feature extraction model provided in the embodiment of the present application is applicable to a variety of learning tasks that have accumulated historical version models, and is not limited to the video field. In actual implementation, the corresponding model f and loss function L can be replaced according to different actual tasks. In addition, the loss function used in the metric learning module is the classic ternary loss function, and other metric loss functions can also be used.
[0140] Second, the prediction stage. In the prediction stage, there is no need for (K-1) historical version models. Only the Kth model of the current version that has been trained is needed. For the video v to be predicted, feature extraction is performed through the Kth model to output the video feature x (K) =f K (v).
[0141] The following is an explanation of the application scenario of the feature extraction model provided in the embodiment of the present application. Taking the feature extraction model as a video feature extraction model and the feature to be extracted as a video feature as an example, the main function of the video feature is to obtain a low-dimensional, dense, floating-point feature vector representation from the video. This feature vector is a summary and generalization of the entire video content, so that the distance between different video features (such as Euclidean distance or cosine distance) reflects the similarity between the corresponding videos. If the semantic content of two videos is close, such as the same type of video, or different episodes of the same TV series, then the video features between them are close and the similarity is high; conversely, if the two videos are not the same type of video, then the video features between them are far and the similarity is low.
[0142] The application of extracting video features through video feature extraction models is very extensive. For example: 1) The video features extracted through the video feature extraction model have stronger representation capabilities. The video features themselves contain a lot of valuable information and can be used as important video recommendation system features; 2) Since the distance between video features reflects the similarity between videos, video retrieval can be performed based on video features. Compared with video retrieval based on text information (such as video title, classification, label, etc.), video features can be used to achieve the effect of searching videos by video. On the basis of video features, a video clip can also be used to retrieve the corresponding complete long video; 3) The extraction of video features can also be used to discover video theft, copying and other behaviors, and can also avoid recommending duplicate video content to users, thereby improving user experience. For example, when the video resolution changes, the opening and ending of the video is modified, watermarks and text are added, video features with similar or even identical values can be obtained, so that content duplication detection can be performed more flexibly; 4) Since video features are a summary and generalization of the semantic information in the video, other tasks such as video title generation and intelligent music matching can be further completed based on video features.
[0143] By applying the above-mentioned embodiments of the present application, the information of the historical version model is used to assist the training of the current version model, and the advantages of each historical version model are fully utilized to improve the feature extraction accuracy of the trained feature extraction model; and although ensemble learning can utilize the advantages of multiple models to achieve better results than a single model, ensemble learning needs to obtain the prediction results of each base model at the same time during the prediction stage. In contrast, the present application only needs to calculate the prediction results of the trained current version model during the prediction stage, and does not need to calculate the prediction results of the historical version, which greatly reduces the calculation time overhead and the corresponding deployment difficulty.
[0144] It is understandable that in the embodiments of the present application, related data such as user information is involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0145] The following describes the training device of the feature extraction model provided in the embodiment of the present application. Figure 8 , Figure 8 6 is a structural diagram of a training device 600 for a feature extraction model provided in an embodiment of the present application. The present application also provides a training device for a feature extraction model, the device comprising:
[0146] The feature extraction module 610 is used to extract features from multiple training samples carrying sample labels based on the feature extraction model of at least one historical version obtained through training, so as to obtain multiple sample features corresponding to each of the historical versions; the determination module 620 is used to determine the sample similarity between any two of the training samples based on the multiple sample features corresponding to each of the historical versions; the selection module 630 is used to select at least one training sample pair from the multiple training samples based on the determined sample similarity, and the training sample pair includes a first training sample and a second training sample; wherein the first training sample and the second training sample satisfy at least one of the following relationships: the sample labels are the same, and among the multiple training samples, the training sample with the smallest sample similarity to the first training sample is the second training sample; the sample labels are different, and among the multiple training samples, the training sample with the largest sample similarity to the first training sample is the second training sample; the training module 640 is used to train the target feature extraction model based on the selected at least one training sample pair to obtain a trained feature extraction model.
[0147] In some embodiments, the determination module 620 is also used to determine the feature similarity between any two sample features corresponding to each of the historical versions; based on the feature similarity between any two sample features corresponding to each of the historical versions, determine the sample similarity between the training samples corresponding to the any two sample features, so as to determine the sample similarity between any two of the training samples.
[0148] In some embodiments, when the number of historical versions is at least two, the determination module 620 is also used to obtain the weight value corresponding to each of the historical versions; based on the weight value corresponding to each of the historical versions, the feature similarity between any two sample features corresponding to each of the historical versions is weighted averaged to obtain the sample similarity between the training samples corresponding to the any two sample features.
[0149] In some embodiments, the determination module 620 is also used to obtain a feature similarity matrix corresponding to each of the historical versions, the (i, j)th matrix element in the feature similarity matrix being the feature similarity between the i-th sample feature and the j-th sample feature corresponding to the corresponding historical version; based on the feature similarity matrix corresponding to each of the historical versions, a sample similarity matrix corresponding to a plurality of the training samples is determined; the (i, j)th matrix element in the sample similarity matrix is used as the sample similarity between the i-th training sample and the j-th training sample in the plurality of the training samples to determine the sample similarity between any two of the training samples; wherein, i and j are both integers greater than zero and not exceeding m, and m is the number of the training samples.
[0150] In some embodiments, the determination module 620 is also used to perform the following processing for each of the historical versions: for the i-th sample feature and the j-th sample feature corresponding to the historical version, determine the feature similarity between the i-th sample feature and the j-th sample feature, and use the feature similarity as the (i, j)-th matrix element in the feature similarity matrix to obtain the feature similarity matrix corresponding to the historical version.
[0151] In some embodiments, when the number of the historical versions is at least two, the determination module 620 is also used to obtain the weight value corresponding to each of the historical versions; based on the weight value corresponding to each of the historical versions, at least two of the feature similarity matrices are weighted averaged to obtain a sample similarity matrix corresponding to multiple training samples.
[0152] In some embodiments, the determination module 620 is also used to obtain the index value of the model evaluation index corresponding to the feature extraction model of each historical version; based on the index value corresponding to the feature extraction model of each historical version, determine the weight value corresponding to the corresponding historical version.
[0153] In some embodiments, the selection module 630 is also used to obtain each training sample pair by performing the following processing: selecting a training sample from the multiple training samples as the first training sample; determining that the training sample whose sample label is the same as the sample label of the first training sample is a positive training sample, and determining that the training sample whose sample label is different from the sample label of the first training sample is a negative training sample; selecting a target training sample from the positive training samples and the negative training samples as the second training sample; wherein the target training sample is at least one of the following training samples: among the positive training samples, the positive training sample with the smallest sample similarity to the first training sample; and among the negative training samples, the negative training sample with the greatest sample similarity to the first training sample.
[0154] In some embodiments, the training module 640 is also used to perform feature extraction on each training sample in the at least one training sample pair through the target feature extraction model to obtain corresponding predicted sample features; obtain the difference between each predicted sample feature and the sample label of the corresponding training sample; based on the difference, update the model parameters of the target feature extraction model to obtain a trained feature extraction model.
[0155] In some embodiments, the second training sample includes: a positive training sample with the same sample label and the smallest sample similarity with the first training sample among the multiple training samples; and a negative training sample with different sample labels and the largest sample similarity with the first training sample among the multiple training samples; the training module 640 is also used to extract the first prediction sample feature corresponding to the first training sample, the second prediction sample feature corresponding to the positive training sample, and the third prediction sample feature corresponding to the negative training sample through the target feature extraction model; determine the first feature similarity between the first prediction sample feature and the second prediction sample feature, and determine the second feature similarity between the first prediction sample feature and the third prediction sample feature; obtain a similarity interval parameter, and construct a loss function of the target feature extraction model based on the first feature similarity, the second feature similarity, and the similarity interval parameter; update the model parameters of the target feature extraction model based on the loss function to obtain a trained feature extraction model.
[0156] In some embodiments, the training module 640 is further used to determine a feature extraction model corresponding to the latest historical version from the feature extraction model of at least one historical version, and determine the feature extraction model corresponding to the latest historical version as the target feature extraction model.
[0157] In some embodiments, the device also includes: a recommendation module; the recommendation module is used to respond to an acquisition request for recommended media information, and based on the trained feature extraction model, respectively extract first media information features of multiple media information to be recommended and second media information features of historical recommended media information; determine the feature similarity between each of the first media information features and the second media information features; based on the determined feature similarity, screen out target recommended media information that matches the acquisition request from multiple media information to be recommended, and return the target recommended media information.
[0158] By applying the above-mentioned embodiments of the present application, first, a feature extraction model of at least one historical version obtained through training is used to perform feature extraction on multiple training samples carrying sample labels, respectively, to obtain multiple sample features corresponding to each historical version; then, based on the multiple sample features corresponding to each historical version, the sample similarity between any two training samples is determined; then, based on the determined sample similarity, at least one training sample pair is selected from the multiple training samples; thus, based on the selected at least one training sample pair, the target feature extraction model is trained to obtain a trained feature extraction model.
[0159] The training sample pair includes a first training sample and a second training sample, and the first training sample and the second training sample satisfy at least one of the following relationships: the sample labels are the same, and among multiple training samples, the training sample with the smallest sample similarity to the first training sample is the second training sample; the sample labels are different, and among multiple training samples, the training sample with the largest sample similarity to the first training sample is the second training sample. In this way, 1) during the training process, two training samples with smaller sample similarity under the same sample label and two training samples with larger similarity under different sample labels can be effectively distinguished, thereby improving the feature extraction accuracy of the feature extraction model obtained through training; 2) by screening the training sample pairs, the time required for each iteration is reduced, thereby improving the training efficiency of the feature extraction model; 3) when there are multiple historical versions, the advantages of the feature extraction models of historical versions with different structures can also be used to assist the training of the target feature extraction model, thereby further improving the feature extraction accuracy of the feature extraction model obtained through training.
[0160] The following describes an electronic device for implementing a method for training a feature extraction model provided in an embodiment of the present application. Fig. 9 , Fig. 9 1 is a schematic diagram of the structure of an electronic device 500 for implementing a training method for a feature extraction model provided in an embodiment of the present application. The electronic device 500 may be a server or a terminal. Figure 1A Taking the server shown in the figure as an example, the electronic device 500 for implementing the training method of the feature extraction model provided in the embodiment of the present application includes: at least one processor 510, a memory 550, at least one network interface 520 and a user interface 530. The various components in the electronic device 500 are coupled together through a bus system 540. It can be understood that the bus system 540 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 540 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, in Fig. 9 Various buses are labeled as bus system 540 .
[0161] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0162] The memory 550 may be removable, non-removable, or a combination thereof. The memory 550 may optionally include one or more storage devices physically located away from the processor 510. The memory 550 may include a volatile memory or a non-volatile memory, or may include both a volatile memory and a non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiments of the present application is intended to include any suitable type of memory.
[0163] The memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or subsets or supersets thereof. In an embodiment of the present application, the memory 550 stores executable instructions; when the executable instructions are executed by the processor 510, the processor 510 will be caused to execute the training method of the feature extraction model provided in the embodiment of the present application.
[0164] The embodiment of the present application also provides a computer program product, which includes a computer program or executable instructions, and the computer program or executable instructions are stored in a computer-readable storage medium. The processor of the electronic device reads the computer program or executable instructions from the computer-readable storage medium, and when the processor executes the computer program or executable instructions, the electronic device executes the training method of the feature extraction model provided in the embodiment of the present application.
[0165] An embodiment of the present application also provides a computer-readable storage medium, which stores executable instructions. When the executable instructions are executed by a processor, the processor will execute the training method of the feature extraction model provided in the embodiment of the present application.
[0166] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EP ROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0167] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0168] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0169] As an example, the executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.
[0170] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A method for training a feature extraction model, characterized in that: The method comprises: At least one historical version feature extraction model obtained through training is used to extract features from multiple training samples carrying sample labels to obtain multiple sample features corresponding to each of the historical versions; Determine the feature similarity between any two sample features corresponding to each of the historical versions; When the number of the historical versions is at least two, obtaining a weight value corresponding to each of the historical versions; Based on the weight values corresponding to the historical versions, weighted average processing is performed on the feature similarities between any two sample features corresponding to the historical versions to obtain the sample similarities between the training samples corresponding to the any two sample features, wherein the weight values corresponding to the historical versions are determined based on the index values of the model evaluation indexes of the feature extraction models of the historical versions; Based on the determined sample similarity, selecting at least one training sample pair from the plurality of training samples, the training sample pair comprising a first training sample and a second training sample; The first training sample and the second training sample satisfy at least one of the following relationships: The training sample with the same sample label and the smallest sample similarity with the first training sample among the multiple training samples is the second training sample; the training sample with different sample labels and the largest sample similarity with the first training sample among the multiple training samples is the second training sample; Based on the selected at least one training sample pair, the target feature extraction model is trained to obtain a trained feature extraction model. The trained feature extraction model can be used to perform feature extraction tasks, and the feature extraction tasks include at least one of the following: video feature extraction tasks and image feature extraction tasks.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining a feature similarity matrix corresponding to each of the historical versions, wherein the (i, j)th matrix element in the feature similarity matrix is the feature similarity between the i-th sample feature and the j-th sample feature corresponding to the corresponding historical version; Determining sample similarity matrices corresponding to the plurality of training samples based on the feature similarity matrices corresponding to the historical versions; The (i, j)th matrix element in the sample similarity matrix is used as the sample similarity between the i-th training sample and the j-th training sample in the plurality of training samples, so as to determine the sample similarity between the training samples corresponding to the any two sample features; Wherein, the i and the j are both integers greater than zero and not exceeding m, and m is the number of the training samples.
3. The method according to claim 2, characterized in that The obtaining of the feature similarity matrix corresponding to each of the historical versions includes: For each of the historical versions, the following processing is performed respectively: For the i-th sample feature and the j-th sample feature corresponding to the historical version, determine the feature similarity between the i-th sample feature and the j-th sample feature, and The feature similarity is used as the (i, j)th matrix element in the feature similarity matrix to obtain the feature similarity matrix corresponding to the historical version.
4. The method according to claim 2, characterized in that The number of the historical versions is at least two, and the determining of the sample similarity matrices corresponding to the plurality of training samples based on the feature similarity matrices corresponding to the historical versions includes: Obtaining weight values corresponding to each of the historical versions; Based on the weight values corresponding to the historical versions, weighted average processing is performed on at least two of the feature similarity matrices to obtain sample similarity matrices corresponding to the plurality of training samples.
5. The method according to claim 1 or 4, characterized in that The obtaining of the weight value corresponding to each of the historical versions includes: Obtaining the index value of the model evaluation index corresponding to the feature extraction model of each of the historical versions; Based on the index value corresponding to the feature extraction model of each of the historical versions, a weight value corresponding to the corresponding historical version is determined.
6. The method according to claim 1, characterized in that The selecting at least one training sample pair from the plurality of training samples based on the determined sample similarity comprises: Each of the training sample pairs is obtained by performing the following processing: Selecting a training sample from the multiple training samples as the first training sample; Determine a training sample whose sample label is the same as the sample label of the first training sample as a positive training sample, and determine a training sample whose sample label is different from the sample label of the first training sample as a negative training sample; Selecting a target training sample from the positive training samples and the negative training samples as the second training sample; The target training sample is at least one of the following training samples: a positive training sample with the smallest sample similarity to the first training sample among the positive training samples; or a negative training sample with the largest sample similarity to the first training sample among the negative training samples.
7. The method according to claim 1, characterized in that The step of training the target feature extraction model based on the selected at least one training sample pair to obtain a trained feature extraction model includes: Extracting features from each training sample in the at least one training sample pair using the target feature extraction model to obtain corresponding prediction sample features; Obtaining the difference between each of the predicted sample features and the sample label of the corresponding training sample; Based on the difference, the model parameters of the target feature extraction model are updated to obtain a trained feature extraction model.
8. The method according to claim 1, characterized in that The second training samples include: a positive training sample with the same sample label and the smallest sample similarity with the first training sample among the multiple training samples; and a negative training sample with different sample labels and the largest sample similarity with the first training sample among the multiple training samples; The step of training the target feature extraction model based on the selected at least one training sample pair to obtain a trained feature extraction model includes: Extracting, by means of the target feature extraction model, a first prediction sample feature corresponding to the first training sample, a second prediction sample feature corresponding to the positive training sample, and a third prediction sample feature corresponding to the negative training sample; Determining a first feature similarity between the first prediction sample feature and the second prediction sample feature, and determining a second feature similarity between the first prediction sample feature and the third prediction sample feature; Acquire a similarity interval parameter, and construct a loss function of the target feature extraction model based on the first feature similarity, the second feature similarity, and the similarity interval parameter; The model parameters of the target feature extraction model are updated based on the loss function to obtain a trained feature extraction model.
9. The method according to claim 1, characterized in that Before training the target feature extraction model based on the selected at least one training sample pair to obtain the trained feature extraction model, the method further includes: From the feature extraction model of at least one historical version, determine the feature extraction model corresponding to the latest historical version, and The feature extraction model corresponding to the latest historical version is determined as the target feature extraction model.
10. The method according to claim 1, characterized in that The method further comprises: In response to a request for obtaining recommended media information, extracting first media information features of a plurality of media information to be recommended and second media information features of historically recommended media information based on the trained feature extraction model; Determining feature similarities between each of the first media information features and the second media information features; Based on the determined feature similarity, target recommended media information matching the acquisition request is screened out from a plurality of media information to be recommended, and the target recommended media information is returned.
11. A training device for a feature extraction model, characterized in that: The device comprises: A feature extraction module, configured to extract features from a plurality of training samples carrying sample labels using a feature extraction model of at least one historical version obtained through training, and obtain a plurality of sample features corresponding to each of the historical versions; A determination module, used to determine the feature similarity between any two sample features corresponding to each of the historical versions; when the number of the historical versions is at least two, obtain a weight value corresponding to each of the historical versions; based on the weight value corresponding to each of the historical versions, perform weighted average processing on the feature similarity between any two sample features corresponding to each of the historical versions to obtain the sample similarity between the training samples corresponding to the any two sample features, wherein the weight value corresponding to the historical version is determined based on the index value of the model evaluation index of the feature extraction model of the historical version; A selection module, configured to select at least one training sample pair from the plurality of training samples based on the determined sample similarity, the training sample pair comprising a first training sample and a second training sample; The first training sample and the second training sample satisfy at least one of the following relationships: The training sample with the same sample label and the smallest sample similarity with the first training sample among the multiple training samples is the second training sample; the training sample with different sample labels and the largest sample similarity with the first training sample among the multiple training samples is the second training sample; A training module is used to train a target feature extraction model based on the selected at least one training sample pair to obtain a trained feature extraction model. The trained feature extraction model can be used to perform feature extraction tasks, and the feature extraction tasks include at least one of the following: video feature extraction tasks and image feature extraction tasks.
12. An electronic device, characterized in that: The electronic device comprises: A memory for storing executable instructions; A processor, used to implement the feature extraction model training method described in any one of claims 1 to 10 when executing the executable instructions stored in the memory.
13. A computer-readable storage medium storing executable instructions, characterized in that: When the executable instructions are executed by the processor, the training method of the feature extraction model described in any one of claims 1 to 10 is implemented.
14. A computer program product comprising a computer program or executable instructions, characterized in that When the computer program or executable instruction is executed by a processor, the training method of the feature extraction model described in any one of claims 1 to 10 is implemented.
