Product matching model training method, product matching method and related device

By performing feature dimensionality reduction and feature splicing on the attention mechanism of the product matching model, the problems of input length limitation and low calculation efficiency are solved, the efficiency and accuracy of product matching are improved, and faster inference time is achieved.

CN118916712APending Publication Date: 2024-11-08PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411063870.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

The existing product matching models have low product matching efficiency due to input length limitations and low computational efficiency, especially when processing large amounts of product data, which is a long time to reason.

Method used

Convolutional calculation of input features of attention mechanism to achieve feature dimensionality reduction, enhance local information of features, and splice the sub-attention features of multiple attention heads to form spliced ​​attention features, including richer text-text , interactive information between image-image, text-image, and improve the model's text image representation ability and product matching efficiency and accuracy.

Benefits of technology

It significantly improves the efficiency and accuracy of the product matching model, shortens the online inference time, and improves the processing ability of input feature length.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916712A_ABST
    Figure CN118916712A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a product matching model training method, a product matching method and a related device, and belongs to the technical field of artificial intelligence. According to the method, convolution calculation is carried out on input features of an attention mechanism to realize feature dimension reduction, local information of the features is enhanced, the calculation amount of attention is reduced, and the limitation of the attention mechanism on the length of the input features is improved; the sub attention features of the plurality of attention heads are spliced to form the spliced attention feature, and the target attention feature is formed according to the sum of the spliced attention feature and the weight matrix of the plurality of attention heads, so that the target attention feature contains richer interaction information. And the text image characterization capability of the model and the product matching efficiency and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a product matching model training method, a product matching method and related devices. Background Art

[0002] Product matching and recommendation based on product images and text descriptions is one of the important services provided by e-commerce platforms. Currently, product matching is mainly achieved by comparing the similarity of the image information and text information of the matching products through a matching model that combines deep learning and traditional machine learning. However, differences in product information (including images, titles, and product descriptions, etc.) and excessive attention calculations limit the input length of the matching model. In addition, the cross-encoder matching structure of the main matching model has low reasoning efficiency. For example, if the database has 1 million stored product data and the user enters a matching product information, the overall online reasoning time of the matching model is: the total number of stored product data*1*t(matching model calculation)+t(similarity calculation). Due to the low calculation efficiency of the matching model, the product matching efficiency is low. Summary of the invention

[0003] The main purpose of the embodiments of the present application is to propose a product matching model training method, a product matching method and related devices, aiming to improve the efficiency and accuracy of product matching.

[0004] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a product matching model training method, comprising:

[0005] Acquire training data, and input the training data into an initial product matching model, wherein the training data includes first training data and second training data, the first training data and the second training data have the same data type, and the first training data and the second training data are provided with similarity labels, and the similarity labels are used to indicate the similarity between the first training data and the second training data;

[0006] Performing an attention calculation operation on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data;

[0007] Predicting the similarity between the first training data and the second training data according to the first attention feature and the second attention feature to obtain a similarity prediction result;

[0008] Adjusting the parameters of the initial product matching model according to the similarity prediction result and the similarity label to obtain a trained product matching model;

[0009] The performing of the attention calculation operation on the training data to obtain the first attention feature of the first training data and the second attention feature of the second training data includes:

[0010] Performing a convolution operation on the training data to obtain fine-grained features;

[0011] determining a query, a key, and a value of an attention mechanism based on the fine-grained features;

[0012] Obtaining a sub-attention feature of an attention head according to the query, the key, and the value;

[0013] The sub-attention features of multiple attention heads are concatenated to obtain a concatenated attention feature, and the target attention feature is obtained according to the sum of the concatenated attention feature and the weight matrices of the multiple attention heads;

[0014] When the training data is the first training data, the target attention feature is the first attention feature; when the training data is the second training data, the target attention feature is the second attention feature.

[0015] In some embodiments, performing a convolution operation on the training data to obtain fine-grained features includes:

[0016] Performing lateral convolution and maximum pooling operations on the training data to obtain fine-grained features.

[0017] In some embodiments, performing an attention calculation operation on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data includes:

[0018] Performing a dimensionality reduction operation on the training data to obtain a first dimensionality reduction feature of the first training data and a second dimensionality reduction feature of the second training data;

[0019] An attention calculation operation is performed on the first dimensionality reduction feature to obtain a first attention feature of the first training data, and an attention calculation operation is performed on the second dimensionality reduction feature to obtain a second attention feature of the second training data.

[0020] In some embodiments, when the data type of the training data is image data; performing a dimensionality reduction operation on the training data to obtain a first dimensionality reduction feature of the first training data and a second dimensionality reduction feature of the second training data includes:

[0021] Extracting features from the training data to obtain two-dimensional image features;

[0022] Flattening the two-dimensional image features to obtain flattened features;

[0023] Adding the flattened feature to the relative position address of the pixel of the training data and a preset image segmentation sequence number to obtain a one-dimensional image feature;

[0024] When the training data is the first training data, the one-dimensional image feature is the first dimensionality reduction feature; when the training data is the second training data, the one-dimensional image feature is the second dimensionality reduction feature.

[0025] In some embodiments, when the data type of the training data is text data; performing a dimensionality reduction operation on the training data to obtain a first dimensionality reduction feature of the first training data and a second dimensionality reduction feature of the second training data includes:

[0026] Perform word segmentation on the training data to obtain word element vectors;

[0027] Adding the word element vector to the text relative position information of the training data and a preset text segmentation sequence number to obtain a one-dimensional text feature;

[0028] When the training data is the first training data, the one-dimensional text feature is the first dimensionality reduction feature; when the training data is the second training data, the one-dimensional text feature is the second dimensionality reduction feature.

[0029] In some embodiments, the attention calculation operation on the training data is performed by an attention module, and the attention module includes multiple attention layers, and the output of the previous attention layer serves as the input of the next attention layer.

[0030] To achieve the above object, a second aspect of an embodiment of the present application proposes a product matching method, comprising:

[0031] Acquire multiple stored product data and product data to be matched;

[0032] Extracting a third attention feature of the stored product data through a trained product matching model;

[0033] Extract the fourth attention feature of the product data to be matched through the trained product matching model;

[0034] Obtaining similarity between the product data to be matched and each of the stored product data according to the third attention feature and the fourth attention feature;

[0035] According to the similarity between the product data to be matched and each of the stored product data, matching and obtaining target stored product data from a plurality of the stored product data;

[0036] The trained product matching model is obtained by training according to the product matching model training method described in the first aspect above.

[0037] To achieve the above-mentioned purpose, a third aspect of an embodiment of the present application proposes a training device for a product matching model, comprising:

[0038] An input module, used to obtain training data, and input the training data into an initial product matching model, wherein the training data includes first training data and second training data, the first training data and the second training data have the same data type, and the first training data and the second training data are provided with similarity labels, and the similarity labels are used to indicate the similarity between the first training data and the second training data;

[0039] a feature extraction module, configured to perform an attention calculation operation on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data;

[0040] A prediction module, configured to predict the similarity between the first training data and the second training data according to the first attention feature and the second attention feature, and obtain a similarity prediction result;

[0041] A parameter adjustment module, used for adjusting the parameters of the initial product matching model according to the similarity prediction result and the similarity label to obtain a trained product matching model;

[0042] The performing of the attention calculation operation on the training data to obtain the first attention feature of the first training data and the second attention feature of the second training data includes:

[0043] Performing a convolution operation on the training data to obtain fine-grained features;

[0044] determining a query, a key, and a value of an attention mechanism based on the fine-grained features;

[0045] Obtaining a sub-attention feature of an attention head according to the query, the key, and the value;

[0046] The sub-attention features of multiple attention heads are concatenated to obtain a concatenated attention feature, and the target attention feature is obtained according to the sum of the concatenated attention feature and the weight matrices of the multiple attention heads;

[0047] When the training data is the first training data, the target attention feature is the first attention feature; when the training data is the second training data, the target attention feature is the second attention feature.

[0048] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes an electronic device, characterized in that the electronic device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, it implements the training method of the product matching model described in the first aspect and the product matching method described in the second aspect.

[0049] To achieve the above-mentioned purpose, the fifth aspect of an embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the training method of the product matching model described in the first aspect and the product matching method described in the second aspect.

[0050] The training method, product matching method and related device of the product matching model proposed in the present application realize feature dimensionality reduction by performing convolution calculation on the input features of the attention mechanism, enhance the local information of the features, reduce the amount of attention calculation, and improve the limitation of the attention mechanism on the length of the input features; by splicing the sub-attention features of multiple attention heads to form a spliced ​​attention feature and forming a target attention feature according to the sum of the spliced ​​attention feature and the weight matrix of multiple attention heads, the target attention feature contains richer text-text, image-image, and text-image interaction information, thereby improving the text image representation ability of the model and the efficiency and accuracy of product matching. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 is a step diagram of a product matching model training method provided in an embodiment of the present application;

[0052] Figure 2 It is a sub-step diagram of step S200 provided in an embodiment of the present application;

[0053] Figure 3 It is a step diagram of performing a dimensionality reduction operation on training data when the data type of the training data is image data provided by an embodiment of the present application;

[0054] Figure 4 It is a step diagram of performing a dimensionality reduction operation on training data when the data type of the training data is text data provided by an embodiment of the present application;

[0055] Figure 5 is a step diagram of the attention layer provided in an embodiment of the present application performing an attention calculation operation on training data;

[0056] Figure 6 is a step diagram of a product matching method provided in an embodiment of the present application;

[0057] Figure 7is a structural diagram of a training device for a product matching model provided in an embodiment of the present application;

[0058] Figure 8 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0060] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0061] 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.

[0062] At present, product matching is mainly achieved by combining deep learning and traditional machine learning matching models to compare the similarity of image information and text information of matching products. However, differences in product information (including images, titles, and product descriptions, etc.) and excessive attention calculations limit the input length of the matching model. In addition, the cross-encoder matching structure of the main matching model has low reasoning efficiency. For example, if there are 1 million product data stored in the database and the user enters a matching product information, the overall online reasoning time of the matching model is 1 million*1*t (matching model calculation) + t (calculation cos). Due to the low calculation efficiency of the matching model, the product matching efficiency is low.

[0063] In order to solve the above problems, the embodiments of the present application provide a product matching model training method, a product matching method and related devices, aiming to improve the efficiency of product matching.

[0064] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, 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.

[0065] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0066] The training method of the product matching model, the product matching method and related devices provided in the embodiments of the present application relate to the field of artificial intelligence technology. The training method of the product matching model and the product matching method provided in the embodiments of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides 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, CDN, and big data and artificial intelligence platforms; the software can be an application of the training method of the product matching model and the product matching method, etc., but is not limited to the above forms.

[0067] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0068] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant regulations. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or jump to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0069] The training method of the product matching model, the product matching method and the related device provided in the embodiment of the present application are specifically described through the following embodiments. First, the training method of the product matching model in the embodiment of the present application is described.

[0070] Reference Figure 1 , the training method of the product matching model includes the following steps:

[0071] Step S100, obtaining training data, and inputting the training data into an initial product matching model;

[0072] Step S200, performing an attention calculation operation on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data;

[0073] Step S300, predicting the similarity between the first training data and the second training data according to the first attention feature and the second attention feature to obtain a similarity prediction result;

[0074] Step S400, adjusting the parameters of the initial product matching model according to the similarity prediction results and the similarity labels to obtain a trained product matching model.

[0075] Among them, an attention calculation operation is performed on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data, including: performing a convolution operation on the training data to obtain fine-grained features; determining the query, key and value of the attention mechanism according to the fine-grained features; obtaining the sub-attention feature of the attention head according to the query, key and value; splicing the sub-attention features of multiple attention heads to obtain a spliced ​​attention feature, and obtaining a target attention feature according to the sum of the spliced ​​attention feature and the weight matrices of the multiple attention heads; when the training data is the first training data, the target attention feature is the first attention feature; when the training data is the second training data, the target attention feature is the second attention feature.

[0076] In this embodiment, convolution calculation is performed on the input features of the attention mechanism to reduce the dimension, enhance the local information of the features, reduce the amount of attention calculation, and improve the limitation of the attention mechanism on the length of the input features; by splicing the sub-attention features of multiple attention heads to form a spliced ​​attention feature and forming a target attention feature according to the sum of the spliced ​​attention feature and the weight matrix of multiple attention heads, the target attention feature contains richer text-text, image-image, and text-image interaction information, thereby improving the model's text image representation ability and the efficiency and accuracy of product matching.

[0077] The following specifically describes steps S100 to S400 in the product matching model training method.

[0078] In step S100 of some embodiments, the training data may be image data, text data, or image data combined with text data. When the training data consists of only image data, the portion corresponding to the text data needs to be padded with 0s; when the training data consists of only text data, the portion corresponding to the image data needs to be padded with 0s.

[0079] There are two groups of training data, including first training data and second training data. The product matching model matches the first training data and the second training data by comparing them. The first training data and the second training data have the same data type; for example, if the first training data is image data, the second training data is also image data; for example, the first training data is an image of a red apple, and the second training data is an image of a banana. If the first training data is text data, the second training data is also text data; for example, the first training data is the text that the apple is very red, and the second training data is the text that the banana is very large. If the first training data is image data combined with text data, the second training data is also image data combined with text data; for example, the first training data contains a red apple image and text that the apple is very red, and the second training data contains a banana image and text that the banana is very large.

[0080] The first training data and the second training data are provided with a similarity label, and the similarity label is used to indicate the similarity between the first training data and the second training data. Specifically, when the first training data is similar to the second training data, the similarity label is 1; when the first training data is not similar to the second training data, the similarity label is 0. For example, if the first training data is a Red Fuji apple image and the second training data is a Jihong apple image, the first training data and the second training data are configured with a similarity label of 1; if the first training data is a red apple image and the second training data is a banana image, the first training data and the second training data are configured with a similarity label of 0. Of course, in other embodiments, the similarity label may also correspond to multiple levels of values, for example, the numerical range of the similarity label is an integer between 1 and 10, and the larger the number, the higher the similarity between the first training data and the second training data.

[0081] Reference Figure 2 In step S200 of some embodiments, performing an attention calculation operation on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data includes the following steps:

[0082] Step S210, performing a dimensionality reduction operation on the training data to obtain a first dimensionality reduction feature of the first training data and a second dimensionality reduction feature of the second training data;

[0083] Step S220, performing an attention calculation operation on the first dimensionality reduction feature to obtain a first attention feature of the first training data, and performing an attention calculation operation on the second dimensionality reduction feature to obtain a second attention feature of the second training data.

[0084] In step S210 of some embodiments, a dimensionality reduction operation is performed on the training data through an embedding layer. Specifically, a dimensionality reduction operation is performed on the first training data through one embedding layer; and a dimensionality reduction operation is performed on the second training data through another embedding layer. Of course, in other embodiments, a common embedding layer can be used to perform dimensionality reduction operations on the first training data and the second training data.

[0085] Reference Figure 3 , when the data type of the training data is image data; performing a dimensionality reduction operation on the training data includes the following steps:

[0086] Step S211, extracting features from the training data to obtain two-dimensional image features;

[0087] Step S212, flattening the two-dimensional image features to obtain flattened features;

[0088] Step S213, adding the flattened feature to the relative position address of the pixel of the training data and the preset image segmentation sequence number to obtain a one-dimensional image feature.

[0089] In this embodiment, the image data is gray-scale transformed and pixel-padded, and the image data is feature extracted by Resnet50 to obtain the two-dimensional image features of the image data, and the two-dimensional image features are flattened to obtain the flattened features, and the flattened features are added to the relative position address of the pixel and the preset image segmentation sequence number segment_id to obtain a one-dimensional feature sequence of the image containing the position information, that is, the one-dimensional image features. The start symbol of the one-dimensional image feature is the token vector representation of isos, and the end symbol is the token vector representation of ieos.

[0090] Specifically, the image segmentation sequence number segment_id is [0, 0, ..., 0]. The size of the image segmentation sequence number is the same as the size of the flattened feature.

[0091] When the training data is the first training data, grayscale transformation and pixel padding are performed on the image data of the first training data, and the image data is feature extracted through Resnet50 to obtain the two-dimensional image features of the image data, and the two-dimensional image features are flattened to obtain flattened features. The flattened features are added to the relative position address of the pixels and the preset image segmentation sequence number segment_id to obtain a one-dimensional image feature containing position information, i.e., the first dimensionality reduction feature. The first dimensionality reduction feature starts with a token vector representation of isos, and ends with a token vector representation of ieos.

[0092] When the training data is the second training data, the image data of the second training data is gray-scale transformed and pixel-filled, and the image data is feature extracted by Resnet50 to obtain the two-dimensional image features of the image data, and the two-dimensional image features are flattened to obtain the flattened features, and the flattened features are added to the relative position address of the pixel and the preset image segmentation sequence number segment_id to obtain the one-dimensional image features containing the position information, i.e., the second dimensionality reduction feature. The second dimensionality reduction feature starts with a token vector representation of isos, and ends with a token vector representation of ieos.

[0093] Reference Figure 4 , when the data type of the training data is text data; performing dimensionality reduction operation on the training data includes the following steps:

[0094] Step S214, performing word segmentation operation on the training data to obtain word element vectors;

[0095] Step S215, adding the word element vector to the text relative position information of the training data and the preset text segmentation sequence number to obtain a one-dimensional text feature;

[0096] In this embodiment, a tokenizer is used to perform a tokenization operation on text data to obtain a word meta-vector, which is the initial representation of the token vector. The dimension size of the word meta-vector is set to be consistent with the dimension size of the pixel point of the image data. The word meta-vector is converted into a text representation matrix, and the text representation matrix is ​​added to the text relative position information of the training data and the preset text segmentation sequence number segment_id to obtain a one-dimensional feature sequence of the text containing the position information, that is, a one-dimensional text feature. Among them, the text relative position information of the text data is represented in the form of a relative position matrix. The text relative position information of the text data can be obtained by obtaining the direct position ID of the word meta-vector of the text data through a function. The start symbol of the one-dimensional text feature is the vector representation of the token of tsos, and the end symbol is the vector representation of the token of teos.

[0097] Specifically, the text segmentation sequence number segment_id is [1,1,...,1]. The size of the text segmentation sequence number is the same as the size of the text representation matrix.

[0098] When the training data is the first training data, the word segmentation operation is performed on the text data of the first training data by the tokenizer to obtain a word element vector, and the word element vector is the initial representation of the token vector. The dimension size of the word element vector is set to be consistent with the dimension size of the pixel point of the image data. The word element vector is converted into a text representation matrix, and the text representation matrix is ​​added to the text relative position information of the training data and the preset text segmentation sequence number segment_id to obtain a one-dimensional text feature containing position information, that is, the first dimensionality reduction feature. Among them, the text relative position information of the text data is represented in the form of a relative position matrix. The text relative position information of the text data can be obtained by obtaining the direct position id of the word element vector of the text data through a function. The first dimensionality reduction feature has a vector representation of a token whose start symbol is tsos, and a vector representation of a token whose end symbol is teos.

[0099] When the training data is the second training data, the word segmentation operation is performed on the text data of the second training data by the tokenizer to obtain a word element vector, and the word element vector is the initial representation of the token vector. The dimension size of the word element vector is set to be consistent with the dimension size of the pixel point of the image data. The word element vector is converted into a text representation matrix, and the text representation matrix is ​​added to the text relative position information of the training data and the preset text segmentation sequence number segment_id to obtain a one-dimensional text feature containing position information, that is, the first dimensionality reduction feature. Among them, the text relative position information of the text data is represented in the form of a relative position matrix. The text relative position information of the text data can be obtained by obtaining the direct position id of the word element vector of the text data through a function. The start symbol of the second dimensionality reduction feature is the vector representation of the token of tsos, and the end symbol is the vector representation of the token of teos.

[0100] Since image data and text data belong to different feature domains, when the training data contains image data and text data, it is necessary to concatenate the one-dimensional image features and the one-dimensional text features by concatenation rather than direct addition, and use the concatenation result as the output of the embedding layer.

[0101] In step S220 of some embodiments, an attention module performs an attention calculation operation on the first dimension reduction feature to obtain a first attention feature of the first training data, and performs an attention calculation operation on the second dimension reduction feature to obtain a second attention feature of the second training data. In this embodiment, an attention module performs an attention calculation operation on the first dimension reduction feature to obtain the first attention feature of the first training data, and another attention module performs an attention calculation operation on the second dimension reduction feature to obtain the second attention feature of the second training data, and the two attention modules share weights.

[0102] The attention module includes multiple attention layers, and the output of the previous attention layer is used as the input of the next attention layer. For example, the attention module includes 6 attention layers; the input of the first attention layer is the output of the embedding layer, the input of the second attention layer is the output of the first attention layer, the input of the third attention layer is the output of the second attention layer, and so on. The output of the sixth attention layer is the first attention feature or the second attention feature.

[0103] Reference Figure 5 , each attention layer performs attention calculation operations on the training data, including the following steps:

[0104] Step S221, performing a convolution operation on the training data to obtain fine-grained features;

[0105] Step S222, determining the query, key and value of the attention mechanism according to the fine-grained features;

[0106] Step S223, obtaining sub-attention features of the attention head according to the query, key and value;

[0107] In step S224, the sub-attention features of multiple attention heads are concatenated to obtain a concatenated attention feature, and the target attention feature is obtained based on the sum of the concatenated attention feature and the weight matrices of multiple attention heads.

[0108] In step S221 of some embodiments, the dimension reduction features corresponding to the training data are subjected to a lateral convolution operation and a maximum pooling operation through a 1*k convolution kernel to obtain fine-grained features. The fine-grained features can be used to distinguish the features of specific details or attributes of different data.

[0109] By introducing convolution calculation on the original feature vector before the calculation of each attention layer, it is beneficial to enhance the local information of the feature, reduce the amount of attention calculation, improve the limitation of the input length of the product matching model based on the original Transformer model (such as BERT, ImageBERT, etc.), and expand the application scope of the system.

[0110] In step S222 of some embodiments, the fine-grained features are combined with the query weight matrix of the i-th attention head of the attention layer Multiply them together to get the query of the i-th attention head of the attention layer, which is expressed in matrix form. The fine-grained features are multiplied by the key weight matrix of the i-th attention head of the attention layer. Multiply them together to get the key of the i-th attention head of the attention layer, which is expressed in matrix form. The fine-grained features are multiplied by the value weight matrix of the i-th attention head of the attention layer. Multiply them together to get the value of the i-th attention head of the attention layer, which is expressed in matrix form. The query weight matrix, key weight matrix, and value weight matrix are randomly assigned initial values ​​at the beginning, and are continuously iterated during the training process until the training is terminated to obtain the final query weight matrix, key weight matrix, and value weight matrix.

[0111] In step S223 of some embodiments, the sub-attention features of the attention head are calculated based on the query, key, value and scaling factor.

[0112] Combining steps S221, S222, and S223, the sub-attention feature of the i-th attention head can be expressed by the following formula: Where X represents the training data, Conv(X) represents the fine-grained features, represents the query weight matrix, represents the key weight matrix, represents the value weight matrix, d k Indicates the scaling factor; a scaling factor of 64 is best.

[0113] and Initial values ​​are randomly assigned at the beginning, and will be adjusted during the training process to continuously iterate until the training is terminated to obtain the final and

[0114] The scaling factor is used to prevent the numerator point product from being too large and the gradient from being too small after passing through softmax, which may interfere with the back propagation.

[0115] In some embodiments, there are 6 attention heads; Rvalue i Where i = 1, 2, 3, 4, 5, 6. Of course, in other embodiments, the number of attention heads is other, such as 10.

[0116] In step S224 of some embodiments, the sub-attention features of multiple attention heads are concatenated to obtain a concatenated attention feature, and the target attention feature is obtained based on the sum of the concatenated attention feature and the weight matrices of the multiple attention heads.

[0117] Specifically, the Rvalue1, Rvalue2, Rvalue3, Rvalue4, Rvalue5 and Rvalue6 matrices are concatenated to obtain the concatenated matrix, i.e., the concatenated attention feature. The sum of the concatenated attention feature and the weight matrices of multiple attention heads W is calculated. o Multiply them together to get the target attention feature of the attention layer.

[0118] The target attention feature can be expressed by the following formula: Rvalue_f = [Rvalue1; ...; Rvalue6]W o Compared with the usual attention features, the target attention feature has lower dimension and enhanced feature local information; it contains richer interactive information between text-text, image-image, and text-image, which improves the model's text-image representation ability and the final matching accuracy.

[0119] The attention module includes 6 attention layers; the target attention feature Rvalue_f output by the first attention layer serves as the input of the first attention layer; the target attention feature Rvalue_f output by the second attention layer serves as the input of the third attention layer; and so on, the target attention feature Rvalue_f output by the fifth attention layer serves as the input of the sixth attention layer; the target attention feature Rvalue_f output by the sixth attention layer serves as the output of the attention module.

[0120] When the training data is the first training data, an attention module is used to perform an attention calculation operation on the first dimension reduction feature corresponding to the first training data; specifically, a convolution operation is performed on the first dimension reduction feature to obtain a fine-grained feature; the query, key and value of the attention mechanism are determined according to the fine-grained feature; the sub-attention feature of the attention head is obtained according to the query, key and value; the sub-attention features of multiple attention heads are concatenated to obtain a concatenated attention feature, and the first attention feature is obtained according to the sum of the concatenated attention feature and the weight matrix of multiple attention heads. The last hidden layer of the attention module outputs the first attention feature a.

[0121] When the training data is the second training data, another attention module performs an attention calculation operation on the second dimension reduction feature corresponding to the second training data; specifically, a convolution operation is performed on the second dimension reduction feature to obtain a fine-grained feature; the query, key and value of the attention mechanism are determined according to the fine-grained feature; the sub-attention feature of the attention head is obtained according to the query, key and value; the sub-attention features of multiple attention heads are concatenated to obtain a concatenated attention feature, and the second attention feature is obtained according to the sum of the concatenated attention feature and the weight matrix of multiple attention heads. The last hidden layer of the attention module outputs the second attention feature b.

[0122] In step S300 of some embodiments, the similarity between the first training data and the second training data is predicted based on the first attention feature and the second attention feature to obtain a similarity prediction result.

[0123] Specifically, the first attention feature a and the second attention feature b are combined and concatenated to obtain the feature [a, b, |ab|]. The feature [a, b, |ab|] is input into a binary classifier based on a multilayer perceptron (MLP). The binary classifier is used to predict the similarity between the first training data and the second training data. The binary classifier outputs a two-dimensional vector, which contains the probability of the corresponding similar category and the probability of the corresponding dissimilar category. The category with the largest probability is taken as the similarity prediction result.

[0124] For example, the first training data is the image data of Red Fuji apples combined with the text data of apples are very red, and the second training data is the image data of Jihong apples combined with the text data of apples are very sweet. The binary classifier outputs a probability of 0.7 for the similar category and a probability of 0.3 for the dissimilar category. The similar category is taken as the similarity prediction result.

[0125] The first training data is the image data of Red Fuji apple images combined with the text data of apples are very red, and the second training data is the image data of banana images combined with the text data of bananas are very large. The binary classifier outputs a probability of 0.2 for the similar category and a probability of 0.8 for the dissimilar category. The dissimilar category is taken as the similarity prediction result.

[0126] In step S400 of some embodiments, the parameters of the initial product matching model are adjusted according to the similarity prediction results and the similarity labels to obtain a trained product matching model.

[0127] The loss function of the product matching model is calculated based on the similarity prediction results and the similarity labels. Specifically, the loss function uses cross entropy loss; of course, in other embodiments, the loss function may also use other types of loss functions, such as mean square error loss, classification loss, etc. In the reverse process, the parameters of the product matching model are adjusted according to the loss function, and the above process is repeated. After multiple iterations of training, until the product matching model converges or the number of training times reaches a preset training number threshold, a trained product matching model is obtained.

[0128] An embodiment of the present application provides a product matching method.

[0129] Reference Figure 6 , product matching methods, including:

[0130] Step S500, obtaining a plurality of stored product data and product data to be matched;

[0131] Step S600, extracting the third attention feature of the stored product data through the trained product matching model;

[0132] Step S700, extracting the fourth attention feature of the product data to be matched through the trained product matching model;

[0133] Step S800, obtaining similarity between the product data to be matched and each stored product data according to the third attention feature and the fourth attention feature;

[0134] Step S900: According to the similarity between the product data to be matched and each stored product data, target stored product data is obtained by matching from multiple stored product data.

[0135] The trained product matching model is obtained by training according to the above product matching model training method.

[0136] The product matching model used for online reasoning can shield or delete the part of the step of executing the similarity prediction result of the first training data and the second training data according to the first attention feature and the second attention feature, and the part of adjusting the parameters of the initial product matching model according to the similarity prediction result and the similarity label to obtain the trained product matching model. Of course, the part of the step of executing the similarity prediction result of the first training data and the second training data according to the first attention feature and the second attention feature, and the part of adjusting the parameters of the initial product matching model according to the similarity prediction result and the similarity label to obtain the trained product matching model can also be retained, and then the parameters of the product matching model can be adjusted according to the result of online reasoning. And add a part of executing the similarity between the product data to be matched and each stored product data according to the third attention feature and the fourth attention feature, and a part of matching the target stored product data from multiple stored product data according to the similarity between the product data to be matched and each stored product data after the attention network.

[0137] In step S500 of some embodiments, multiple stored product data and product data to be matched are obtained. The stored product data is product data stored in a database of a server. The product data to be matched is product data input by a user through a client. The purpose is to match the target stored product data with the highest matching degree with the product data to be matched from the multiple stored product data through the product data to be matched input by the user. The product data to be matched does not have a similarity tag.

[0138] In step S600 of some embodiments, since the products in the database are relatively fixed, the stored product data can be pre-extracted offline, and the third attention feature of the stored product data can be extracted through the trained product matching model. In the online reasoning process, it is only necessary to extract the attention feature of the product data to be matched through the product matching model. This is conducive to improving the efficiency of online model reasoning.

[0139] In step S700 of some embodiments, the fourth attention feature of the product data to be matched is extracted through the trained product matching model.

[0140] Specifically, the embedded layer of the trained product matching model is first used to reduce the dimension of the product data to be matched. When the product data to be matched contains image data, grayscale transformation and pixel padding are performed on the image data, and the two-dimensional image features of the image data are obtained by feature extraction through Resnet50. The two-dimensional image features are flattened to obtain flattened features, and the flattened features are added to the relative position address of the pixel and the preset image segmentation sequence segment_id to obtain a one-dimensional feature sequence of the image containing position information, that is, a one-dimensional image feature. The start symbol of the one-dimensional image feature is the token vector representation of isos, and the end symbol is the token vector representation of ieos. When the product data to be matched contains text data, the word segmentation operation is performed on the text data through the tokenizer to obtain a word meta vector, which is the initial representation of the token vector. The dimension size of the word meta vector is set to be consistent with the dimension size of the pixel point of the image data. Convert the word element vector to a text representation matrix, add the text representation matrix to the text relative position information of the training data and the preset text segmentation sequence number segment_id, and obtain a one-dimensional feature sequence of the text containing the position information, that is, a one-dimensional text feature. Among them, the text relative position information of the text data is represented in the form of a relative position matrix. The text relative position information of the text data can be obtained by obtaining the direct position id of the word element vector of the text data through a function. The start symbol of the one-dimensional text feature is the vector representation of the token of tsos, and the end symbol is the vector representation of the token of teos. Concatenate the one-dimensional image feature and the one-dimensional text feature.

[0141] When the product data to be matched has only a single mode, the missing mode sequence is filled with 0. For example, when the product data to be matched contains only image data, the missing text data is filled with 0; when the product data to be matched contains only text data, the missing image data is filled with 0.

[0142] Then, the attention module performs an attention calculation operation on the dimensionality reduction features of the product data to be matched output by the embedding layer to obtain the fourth attention features of the product data to be matched.

[0143] Specifically, the attention module includes 6 attention layers; the input of the first attention layer is the output of the embedding layer, the input of the second attention layer is the output of the first attention layer, the input of the third attention layer is the output of the second attention layer, and so on. The output of the sixth attention layer is the first attention feature or the second attention feature. Each attention layer performs an attention calculation operation on the dimensionality reduction features of the product data to be matched, including the following steps: performing a lateral convolution operation and a maximum pooling operation on the dimensionality reduction features of the product data to be matched through a 1*k convolution kernel to obtain fine-grained features. Fine-grained features can be used to distinguish the specific details or attribute features of different data. The fine-grained features are combined with the query weight matrix of the i-th attention head of the attention layer. Multiply them together to get the query of the i-th attention head of the attention layer, which is expressed in matrix form. The fine-grained features are multiplied by the key weight matrix of the i-th attention head of the attention layer. Multiply them together to get the key of the i-th attention head of the attention layer, which is expressed in matrix form. The fine-grained features are multiplied by the value weight matrix of the i-th attention head of the attention layer. Multiply them together to get the value of the i-th attention head of the attention layer, which is expressed in matrix form.

[0144] The sub-attention features of the attention head are calculated based on the query, key, value and scaling factor. The sub-attention features of the i-th attention head can be expressed as follows: Where X represents the training data, Conv(X) represents the fine-grained features, represents the query weight matrix, represents the key weight matrix, represents the value weight matrix, d k Represents the scaling factor; the scaling factor is 64. There are 6 attention heads; Rvalue i i=1,2,3,4,5,6.

[0145] The sub-attention features of multiple attention heads are concatenated to obtain a concatenated attention feature, and the target attention feature is obtained according to the sum of the concatenated attention feature and the weight matrices of multiple attention heads. The concatenated matrix, i.e., the concatenated attention feature, is concatenated by concatenating the Rvalue1, Rvalue2, Rvalue3, Rvalue4, Rvalue5, and Rvalue6 matrices. The target attention feature of the attention layer is obtained by multiplying the concatenated attention feature and the sum of the weight matrices of multiple attention heads, W°. The target attention feature can be expressed by the following formula: Rvalue_f=[Rvalue1;...;Rvalue6]W°. The attention module includes 6 attention layers; the target attention feature Rvalue_f output by the first attention layer is used as the input of the first attention layer; the target attention feature Rvalue_f output by the second attention layer is used as the input of the third attention layer; and so on, the target attention feature Rvalue_f output by the fifth attention layer is used as the input of the sixth attention layer; the target attention feature Rvalue_f output by the sixth attention layer is used as the output of the attention module, and the fourth attention feature of the product data to be matched is obtained.

[0146] In step S800 of some embodiments, the similarity between the product data to be matched and each stored product data is obtained based on the third attention feature and the fourth attention feature. During online reasoning, the similarity between the product data to be matched and the stored product data is obtained by calculating the cosine value between the third attention feature and the fourth attention feature. The closer the cosine value is to 1, the closer the angle is to 0 degrees, indicating that the two vectors are more similar, further indicating that the product data to be matched is more similar to the stored product data; the closer the cosine value is to 0, the closer the angle is to 90 degrees, indicating that the two vectors are less similar, that is, further indicating that the product data to be matched is less similar to the stored product data.

[0147] In step S900 of some embodiments, target stored product data is matched from multiple stored product data according to the similarity between the product data to be matched and each stored product data. Specifically, the stored product data with the highest similarity is used as the target stored product data; further, the five stored product data with the highest cosine values ​​are output to the client as the target stored product data.

[0148] The online reasoning time of this product matching method is shortened to 1*t (matching model calculation) + t (similarity calculation), which improves the matching efficiency.

[0149] In this embodiment, by performing convolution calculations on the input features of the attention mechanism to achieve feature dimensionality reduction, local feature information is enhanced, the amount of attention calculation is reduced, and the limitation of the attention mechanism on the length of input features is improved; by splicing the sub-attention features of multiple attention heads to form a spliced ​​attention feature and forming a target attention feature based on the sum of the spliced ​​attention feature and the weight matrix of multiple attention heads, the target attention feature contains richer text-text, image-image, and text-image interaction information, thereby improving the model's text-image representation ability and the efficiency and accuracy of product matching.

[0150] The embodiment of the present application provides a training device for a product matching model, which includes an input module 801 , a feature extraction module 802 , a prediction module 803 and a parameter adjustment module 804 .

[0151] The input module 801 is used to obtain training data and input the training data into the initial product matching model, wherein the training data includes first training data and second training data, the first training data and the second training data have the same data type, and the first training data and the second training data are provided with similarity labels, and the similarity labels are used to indicate the similarity between the first training data and the second training data.

[0152] The feature extraction module 802 is used to perform an attention calculation operation on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data.

[0153] The prediction module 803 is used to predict the similarity between the first training data and the second training data according to the first attention feature and the second attention feature to obtain a similarity prediction result.

[0154] The parameter adjustment module 804 is used to adjust the parameters of the initial product matching model according to the similarity prediction results and the similarity labels to obtain a trained product matching model.

[0155] Among them, the attention calculation operation is performed on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data, including: performing a convolution operation on the training data to obtain fine-grained features; determining the query, key and value of the attention mechanism according to the fine-grained features; obtaining a sub-attention feature of the attention head according to the query, the key and the value; splicing the sub-attention features of multiple attention heads to obtain a spliced ​​attention feature, and obtaining a target attention feature according to the sum of the spliced ​​attention feature and the weight matrices of multiple attention heads; when the training data is the first training data, the target attention feature is the first attention feature; when the training data is the second training data, the target attention feature is the second attention feature.

[0156] It is understandable that the training device for the product matching module of the embodiment of the present application applies the training method for the product matching module as described above. The modules of the training device for the product matching module of the embodiment of the present application correspond to the steps of the training method for the product matching module. The training device for the product matching module and the training method for the product matching module adopt the same technical means, solve the same technical problems, and bring the same technical effects, which will not be repeated here.

[0157] The present application also provides an electronic device. Figure 8 The electronic device includes a memory 902 and a processor 901. The memory 902 stores a computer program. When the processor 901 executes the computer program, the training method of the product matching model and the product matching method are implemented. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0158] The processor 901 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application; the memory 902 can be implemented in the form of a read-only memory (Read Only Memory, ROM), a static storage device, a dynamic storage device, or a random access memory (Random Access Memory, RAM). The memory 902 can store operating systems and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 902, and the processor 901 is used to call and execute the training method and product matching method of the product matching model of the embodiments of the present application.

[0159] The input / output interface 903 is used to realize information input and output; the communication interface 904 is used to realize communication interaction between this device and other devices, and communication can be realized through wired methods (such as USB, network cable, etc.) or wireless methods (such as mobile network, WIFI, Bluetooth, etc.); the bus 905 transmits information between the various components of the device (such as the processor 901, the memory 902, the input / output interface 903 and the communication interface 904); wherein the processor 901, the memory 902, the input / output interface 903 and the communication interface 904 realize communication connection with each other within the device through the bus 905.

[0160] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the training method and product matching method of the above-mentioned product matching model.

[0161] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0162] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0163] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0164] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0165] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0166] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0167] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0168] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0169] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0170] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0171] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0172] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A product matching model training method, characterized in that: include: Acquire training data, and input the training data into an initial product matching model, wherein the training data includes first training data and second training data, the first training data and the second training data have the same data type, and the first training data and the second training data are provided with similarity labels, and the similarity labels are used to indicate the similarity between the first training data and the second training data; Performing an attention calculation operation on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data; Predicting the similarity between the first training data and the second training data according to the first attention feature and the second attention feature to obtain a similarity prediction result; Adjusting the parameters of the initial product matching model according to the similarity prediction result and the similarity label to obtain a trained product matching model; The performing of the attention calculation operation on the training data to obtain the first attention feature of the first training data and the second attention feature of the second training data includes: Performing a convolution operation on the training data to obtain fine-grained features; determining a query, a key, and a value of an attention mechanism based on the fine-grained features; Obtaining a sub-attention feature of an attention head according to the query, the key, and the value; The sub-attention features of multiple attention heads are concatenated to obtain a concatenated attention feature, and the target attention feature is obtained according to the sum of the concatenated attention feature and the weight matrices of the multiple attention heads; When the training data is the first training data, the target attention feature is the first attention feature; when the training data is the second training data, the target attention feature is the second attention feature.

2. The product matching model training method according to claim 1, characterized in that: The performing a convolution operation on the training data to obtain fine-grained features includes: Performing lateral convolution and maximum pooling operations on the training data to obtain fine-grained features.

3. The product matching model training method according to claim 1, characterized in that: The performing an attention calculation operation on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data includes: Performing a dimensionality reduction operation on the training data to obtain a first dimensionality reduction feature of the first training data and a second dimensionality reduction feature of the second training data; An attention calculation operation is performed on the first dimensionality reduction feature to obtain a first attention feature of the first training data, and an attention calculation operation is performed on the second dimensionality reduction feature to obtain a second attention feature of the second training data.

4. The product matching model training method according to claim 3, characterized in that: When the data type of the training data is image data; performing a dimensionality reduction operation on the training data to obtain a first dimensionality reduction feature of the first training data and a second dimensionality reduction feature of the second training data includes: Extracting features from the training data to obtain two-dimensional image features; Flattening the two-dimensional image features to obtain flattened features; Adding the flattened feature to the relative position address of the pixel of the training data and a preset image segmentation sequence number to obtain a one-dimensional image feature; When the training data is the first training data, the one-dimensional image feature is the first dimensionality reduction feature; when the training data is the second training data, the one-dimensional image feature is the second dimensionality reduction feature.

5. The product matching model training method according to claim 3, characterized in that: When the data type of the training data is text data; performing a dimensionality reduction operation on the training data to obtain a first dimensionality reduction feature of the first training data and a second dimensionality reduction feature of the second training data includes: Perform word segmentation on the training data to obtain word element vectors; Adding the word element vector to the text relative position information of the training data and a preset text segmentation sequence number to obtain a one-dimensional text feature; When the training data is the first training data, the one-dimensional text feature is the first dimensionality reduction feature; when the training data is the second training data, the one-dimensional text feature is the second dimensionality reduction feature.

6. The product matching model training method according to claim 1, characterized in that: The attention calculation operation on the training data is performed by an attention module, and the attention module includes multiple attention layers, and the output of the previous attention layer serves as the input of the next attention layer.

7. A product matching method, characterized in that: include: Acquire multiple stored product data and product data to be matched; Extracting a third attention feature of the stored product data through a trained product matching model; Extract the fourth attention feature of the product data to be matched through the trained product matching model; Obtaining similarity between the product data to be matched and each of the stored product data according to the third attention feature and the fourth attention feature; According to the similarity between the product data to be matched and each of the stored product data, matching and obtaining target stored product data from a plurality of the stored product data; The trained product matching model is obtained by training according to the product matching model training method according to any one of claims 1 to 6.

8. A training device for a product matching model, characterized in that: include: An input module, used to obtain training data, and input the training data into an initial product matching model, wherein the training data includes first training data and second training data, the first training data and the second training data have the same data type, and the first training data and the second training data are provided with similarity labels, and the similarity labels are used to indicate the similarity between the first training data and the second training data; a feature extraction module, configured to perform an attention calculation operation on the training data to obtain a first attention feature of the first training data and a second attention feature of the second training data; A prediction module, configured to predict the similarity between the first training data and the second training data according to the first attention feature and the second attention feature, and obtain a similarity prediction result; A parameter adjustment module, used for adjusting the parameters of the initial product matching model according to the similarity prediction result and the similarity label to obtain a trained product matching model; The performing of the attention calculation operation on the training data to obtain the first attention feature of the first training data and the second attention feature of the second training data includes: Performing a convolution operation on the training data to obtain fine-grained features; determining a query, a key, and a value of an attention mechanism based on the fine-grained features; Obtaining a sub-attention feature of an attention head according to the query, the key, and the value; The sub-attention features of multiple attention heads are concatenated to obtain a concatenated attention feature, and the target attention feature is obtained according to the sum of the concatenated attention feature and the weight matrices of the multiple attention heads; When the training data is the first training data, the target attention feature is the first attention feature; when the training data is the second training data, the target attention feature is the second attention feature.

9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the product matching model training method described in any one of claims 1 to 6 and the product matching method described in claim 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the product matching model training method described in any one of claims 1 to 6 and the product matching method described in claim 7 are implemented.