Merchandise vectorization method, device, computer system, and storage medium
By constructing the co-occurrence matrix and co-value matrix of product browsing records and combining them with a regression model to optimize the product vectorization method, the problems of high complexity and insufficient global co-occurrence information in existing technologies are solved, and efficient and accurate representation of product vectors is achieved.
Patent Information
- Application Number
- CN202110375169.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-07
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2041-04-07
AI Technical Summary
Existing product vectorization methods suffer from high complexity, unrealistic statistical weighting of products, and an inability to consider global co-occurrence information and individual differences, leading to vector learning bias and making them difficult to apply effectively in actual production.
Based on browsing records within a preset time period, a product sequence is generated, a co-occurrence matrix and a co-value matrix are constructed, a fusion matrix is obtained through weighted fusion, and a product vectorization model is optimized using a regression model. Considering global and individual differences, a gradient descent algorithm is used to train the vector representation of the products.
It improves the accuracy and efficiency of product vector representation, reduces training costs, and better reflects the similarity and correlation of products, making it suitable for real-world production environments.
Smart Images

Figure CN113779376B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of computer technology, and more particularly, to a commodity vectorization method and device, a computer system and a storage medium. BACKGROUND
[0002] In the field of commodity recommendation, etc., the vector representation of commodities (Items) is often regarded as a basic work. Many downstream tasks are based on commodity vectors, such as calculating the cosine distance of vectors to obtain the similarity of two commodities, and commodity vectors can also be used as the input of many complex computing models.
[0003] The method of vectorizing commodity representation can be roughly summarized into three methods, namely embedding method based on traditional dimension reduction algorithm (such as SVD), embedding method based on sequence model (seq-embedding), and embedding method based on graph algorithm (graph-embedding). Among them, SVD compresses and reduces the discrete feature matrix, and uses the left singular matrix and the largest m singular values to construct commodity vectors. This method has high complexity, and it is consistent for the statistical weight of all commodities, which is not consistent with reality, and it performs poorly in general tasks. The embedding based on sequence model, namely Item2vec, is realized based on the skip-gram algorithm combined with negative sampling in natural language processing. This algorithm only makes predictions in a specific window without considering global co-occurrence information. Although negative sampling is added, there is a bias in the vectors learned for the middle and tail commodities because the feature differences between commodities are not considered. The embedding based on graph algorithm is limited by the need for large-scale high-quality data and complex model design, and often cannot be well implemented in actual production. SUMMARY
[0004] In view of this, the present disclosure provides a commodity vectorization method, comprising: generating at least one commodity sequence based on commodity browsing records within a preset time period; generating a co-occurrence matrix based on the number of co-occurrences between different category commodities in the at least one commodity sequence, and generating a co-value matrix based on the number of co-values of attributes between different category commodities in the at least one commodity sequence; weighting and fusing the co-occurrence matrix and the co-value matrix to obtain a fusion matrix; inputting the fusion matrix into a preset commodity vectorization model and optimizing the commodity vectorization model to obtain a vector representation of each commodity; wherein the parameters of the commodity vectorization model at least include a first matrix, a second matrix and the fusion matrix, each row vector of the first matrix is a first vector of one commodity, each row vector of the second matrix represents a second vector of one commodity, and the first vector and the second vector jointly constitute the vector representation of the corresponding commodity, and the commodity vectorization model is optimized to obtain the optimal vector representation of each commodity.
[0005] According to an embodiment of the present disclosure, the generating at least one commodity sequence based on commodity browsing records within a preset time period comprises: determining whether the browsing interval between each adjacent commodity in the commodity browsing records exceeds a first preset time length; when the browsing interval of two adjacent commodities exceeds the first preset time length, the commodity browsing records are divided into two segments with the browsing interval as the division point, and a commodity sequence is generated according to each segment of the commodity browsing records, the commodity sequence being composed of commodities arranged in browsing order.
[0006] According to an embodiment of the present disclosure, it further comprises: removing the commodities in the commodity sequence whose browsing time length does not reach a second preset time length; deduplicating the same commodity continuously appearing in the commodity sequence; and removing the commodity sequences whose length is less than or equal to 2.
[0007] According to an embodiment of the present disclosure, the generating a co-occurrence matrix based on the number of co-occurrences between different category commodities in the at least one commodity sequence, and generating a co-value matrix based on the number of co-values of attributes between different category commodities in the at least one commodity sequence comprises: sequentially taking each commodity in the commodity sequence as a center commodity, and intercepting a sub-sequence of a preset length from the commodity sequence; counting the number of co-occurrences of the center commodity and other commodities in the sub-sequence; counting the total number of co-occurrences between each commodity in the commodity sequence based on the number of co-occurrences counted by each sub-sequence; constructing the co-occurrence matrix based on the total number of co-occurrences; and counting the number of co-values of attributes of each commodity in the commodity sequence and other commodities in the commodity sequence, and constructing the co-value matrix based on the number of co-values.
[0008] According to an embodiment of the present disclosure, the row index and the column index of each element in the co-occurrence matrix and the co-value matrix represent the serial number of one of the commodities in the commodity sequence, the element in the co-occurrence matrix represents the total number of co-occurrences of two of the commodities in the commodity sequence, and the element in the co-value matrix represents the number of co-values of two of the commodities in the commodity sequence.
[0009] According to an embodiment of the present disclosure, the weighting and fusing of the co-occurrence matrix and the co-value matrix to obtain a fusion matrix comprises: assigning a first weight to the co-occurrence matrix and a second weight to the co-value matrix, wherein the sum of the first weight and the second weight is 1; calculating the product of the co-occurrence matrix and the first weight, the product of the co-value matrix and the second weight, summing the products to obtain the fusion matrix.
[0010] According to an embodiment of the present disclosure, the commodity model comprises a regression function, a weight function and a regularization term, wherein the regression function is a function representing the relationship between the first vector and the second vector of the commodity, used for learning the first matrix and the second matrix, the weight function is a function of the corresponding weight represented by the regression function of each commodity, used for suppressing noise in the regression function, and the regularization term is used to prevent overfitting of the commodity vectorization model.
[0011] According to an embodiment of the present disclosure, the inputting of the fusion matrix into a preset commodity vectorization model and the optimization of the commodity vectorization model to obtain the vector representation of each commodity comprises: randomly selecting a preset number of non-zero, non-diagonal elements from the fusion matrix and inputting the elements into the commodity vectorization model; training the first matrix and the second matrix in the commodity vectorization model by using a gradient descent algorithm; repeating the above steps until the commodity vectorization model converges to obtain optimal first matrix and second matrix; obtaining the first vector and the second vector of each commodity according to the first matrix and the second matrix, calculating the sum of the first vector and the second vector to obtain the vector representation of the commodity.
[0012] Another aspect of the present disclosure provides a product vectorization device, including: a product sequence generation module, used to generate at least one product sequence based on product browsing records within a preset time period; a matrix data acquisition module, used to generate a co-occurrence matrix based on the number of co-occurrences between products of different categories in the at least one product sequence, and to generate a co-value matrix based on the number of co-values of attributes between products of different categories in the at least one product sequence; a matrix fusion module, used to weightedly fuse the co-occurrence matrix and the co-value matrix to obtain a fusion matrix; a vector generation module, used to input the fusion matrix into a preset product vectorization model, and optimize the product vectorization model to obtain vectors of each product, wherein the parameters of the product vectorization model include at least a first matrix, a second matrix and the fusion matrix, each row vector of the first matrix is a first vector of the product, each row vector of the second matrix represents a second vector of the product, the first vector and the second vector together constitute the corresponding vector representation of the product, and the optimal vector representation of each product is obtained by optimizing the product vectorization model.
[0013] Another aspect of the present disclosure provides a computer system, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the first aspects.
[0014] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the method described above when executed.
[0015] According to the embodiments of the present disclosure, a co-occurrence matrix is constructed in the user's browsing sequence to obtain global co-occurrence information. The co-value matrix is used to characterize fine-grained differences in product attribute values, further strengthening the characterization of products. The co-occurrence matrix and the co-value matrix are used to construct a fusion matrix, and then a regression model is used to learn product vectors. During the training phase, sampling is performed on the non-zero elements of the fusion matrix, significantly reducing training costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0017] Figure 1 An exemplary system architecture to which the commodity vectorization method of the present disclosure can be applied is schematically shown.
[0018] Figure 2 Schematically shows a flow chart of a commodity quantization method according to an embodiment of the present disclosure;
[0019] Figure 3 A flowchart schematically illustrating a commodity vectorization method according to an embodiment of the present disclosure is shown;
[0020] Figure 4 A block diagram schematically illustrating a commodity vectorization apparatus according to an embodiment of the present disclosure is shown;
[0021] Figure 5 A block diagram of a computer system 500 suitable for implementing a robot according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0022] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood, however, that the description which follows is merely illustrative and is not intended to limit the scope of the present disclosure. In the following detailed description of embodiments of the present disclosure, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure. However, it will be apparent to one skilled in the art that one or more embodiments of the present disclosure can be practiced without these specific details. In other instances, well-known structures and functions have not been described in detail in order to avoid obscuring aspects of the present disclosure.
[0023] The terms used herein are merely used to describe specific embodiments and are not intended to limit the present disclosure. The terms "include" and "have" and the like used herein indicate the presence of the described features, steps, operations, and / or components but do not preclude the presence or addition of one or more other features, steps, operations, or components.
[0024] All terms used herein, including technical and scientific terms, have the same meanings as those generally understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having meanings that are consistent with the context of the present description, and should not be interpreted in an idealized or excessively formal manner.
[0025] In the case of using expressions similar to "at least one of A, B, and C, etc.", it should generally be interpreted to include at least one of each item enumerated, but not a combination of the items. In the case of using expressions similar to "at least one of A, B, or C, etc.", it should generally be interpreted to include at least one of each item enumerated, but not a combination of the items. In the case of using expressions similar to "at least one of A, B, and C, etc.", it should generally be interpreted to include at least one of each item enumerated, but not a combination of the items. In the case of using expressions similar to "at least one of A, B, or C, etc.", it should generally be interpreted to include at least one of each item enumerated, but not a combination of the items.
[0026] Embodiments of the present disclosure provide a commodity vectorization method, device, computer system and storage medium. The method comprises generating at least one commodity sequence based on commodity browsing records in a preset time period, generating a co-occurrence matrix based on the number of co-occurrences between different category commodities in the at least one commodity sequence, and generating a co-value matrix based on the number of co-values of attributes between different category commodities in the at least one commodity sequence, weighting and fusing the co-occurrence matrix and the co-value matrix to obtain a fusion matrix, and inputting the fusion matrix into a preset commodity vectorization model to obtain a vector of each commodity, wherein the commodity vectorization model is a regression model considering globality and individual difference.
[0027] Figure 1 An exemplary system architecture 100 to which the commodity vectorization method according to embodiments of the present disclosure can be applied is schematically shown. It should be noted that, Figure 1 The system architecture shown is only an example of the system architecture to which embodiments of the present disclosure can be applied, to help those skilled in the art understand the technical content of the present disclosure, but does not mean that embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0028] As Figure 1 shown, the system architecture 100 according to this embodiment can include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 can include various connection types, such as wired and / or wireless communication links, etc.
[0029] Users can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc. (only as examples).
[0030] The terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smartphones, tablet computers, laptop computers and desktop computers, etc.
[0031] The server 105 can be a server providing various services, such as a background management server providing support for websites browsed by users using the terminal devices 101, 102, 103 (only as an example). The background management server can analyze and process received user requests and other data, and feed back the processing results (such as web pages, information or data obtained or generated according to user requests, etc.) to the terminal devices.
[0032] It should be noted that the commodity vectorization method provided by the embodiments of the present disclosure can be generally executed by the server 105. Accordingly, the commodity vectorization apparatus provided by the embodiments of the present disclosure can be generally arranged in the server 105. The commodity vectorization method provided by the embodiments of the present disclosure can also be executed by a server or a server cluster different from the server 105 and capable of communicating with the terminal device 101, 102, 103 and / or the server 105. Accordingly, the commodity vectorization apparatus provided by the embodiments of the present disclosure can also be arranged in a server or a server cluster different from the server 105 and capable of communicating with the terminal device 101, 102, 103 and / or the server 105. Alternatively, the commodity vectorization method provided by the embodiments of the present disclosure can also be executed by the terminal device 101, 102, or 103, or by other terminal devices different from the terminal device 101, 102, or 103. Accordingly, the commodity vectorization apparatus provided by the embodiments of the present disclosure can also be arranged in the terminal device 101, 102, or 103, or in other terminal devices different from the terminal device 101, 102, or 103.
[0033] For example, the commodity browsing records can be originally stored in any one of the terminal devices 101, 102, or 103 (for example, the terminal device 101, but not limited thereto), or stored on an external storage device and can be imported into the terminal device 101. Then, the terminal device 101 can execute the image processing method provided by the embodiments of the present disclosure locally, or send the commodity browsing records to other terminal devices, servers, or server clusters, and execute the image processing method provided by the embodiments of the present disclosure by other terminal devices, servers, or server clusters receiving the commodity browsing records.
[0034] It should be understood that Figure 1 The number of terminal devices, networks and servers in the system is only illustrative. According to the needs of implementation, there can be any number of terminal devices, networks and servers.
[0035] Figure 2 A flowchart of a commodity vectorization method according to an embodiment of the present disclosure is schematically shown.
[0036] As Figure 2 shown, the method comprises operations S210-S240.
[0037] Operation S210, generating at least one commodity sequence based on commodity browsing records in a preset time period.
[0038] Operation S220, generating a co-occurrence matrix based on the number of co-occurrences between different category commodities in the at least one commodity sequence, and generating a co-value matrix based on the number of co-values of attributes between different category commodities in the at least one commodity sequence.
[0039] Operation S230, the co-occurrence matrix and the co-value matrix are weighted and fused to obtain a fusion matrix.
[0040] Operation S240, the fusion matrix is input into a preset commodity vectorization model, and the commodity vectorization model is optimized to obtain a vector representation of each commodity; wherein parameters of the commodity vectorization model at least include the first matrix and the second matrix and the fusion matrix, each row vector of the first matrix is a first vector of one commodity, each row vector of the second matrix represents a second vector of one commodity, and the first vector and the second vector jointly constitute a vector representation of the corresponding commodity, and the commodity vectorization model is optimized to obtain an optimal vector representation of each commodity.
[0041] The purpose of commodity vectorization is to describe the similarity and relevance of commodities through mathematical representation. If the behavior of a user in a period of time is referred to as a set, such as commodity browsing records, it can be considered that commodities appearing in the same set in a static environment are similar and regarded as positive samples. Even if the order in which they are produced is not considered, if two commodities frequently co-occur, the vector representations of the two commodities can also be similar.
[0042] In the embodiments of the present disclosure, the commodity browsing records of a user in a period of time are defined as a commodity sequence, and a co-occurrence matrix is constructed based on the sequence to represent global co-occurrence information. Meanwhile, for commodities themselves, the number of attributes commonly owned by commodities is a more direct similarity measurement method, so a co-value matrix between commodities is constructed based on the structured attribute-value of commodities.
[0043] According to the embodiments of the present disclosure, global information of commodity sequences is obtained by constructing a co-occurrence matrix, individual difference information of commodity sequences is obtained by constructing a co-value matrix, and a commodity vectorization model considering both globality and individual difference is constructed based on the co-occurrence matrix and the co-value matrix, so as to more accurately learn the vectors of commodities.
[0044] In the embodiments of the present disclosure, operation S210 includes S211-S212.
[0045] Operation S211, it is determined whether the browsing interval between each adjacent commodity in the commodity browsing records exceeds a first preset time length.
[0046] Operation S212, when the browsing interval of two adjacent commodities exceeds the preset time length, the commodity browsing records are divided into two segments with the browsing interval as a segmentation point, and a commodity sequence is generated according to each segment of commodity browsing records, and the commodity sequence is composed of commodities arranged in browsing order.
[0047] According to an embodiment of the present disclosure, the initially obtained commodity browsing records are records in a preset time period, for example, can be user browsing records in the last 1 month, in order to make the commodity co-occurrence number meaningful, avoid losing the ability to judge the commodity commonality due to too large data sample, if the browsing interval of two adjacent commodities exceeds the first preset time length, it is explained that the user has no action in this preset time length, and the two commodities can be irrelevant, therefore, the commodity browsing records are separated.
[0048] The preprocessing of the commodity sequence further includes operations S213-S215.
[0049] S213, removing commodities in the commodity sequence whose browsing time length does not reach a second preset time length.
[0050] According to an embodiment of the present disclosure, the second preset time length can be 1 second, 3 seconds, 5 seconds or more, if the browsing time length of a commodity does not reach the second preset time length, it is explained that this commodity information can be meaningless, removing such commodities can reduce the data amount participating in the subsequent calculation, and improve the calculation efficiency.
[0051] S214, removing the same commodity continuously appearing in the commodity sequence.
[0052] According to an embodiment of the present disclosure, the same commodity can appear multiple times in the same commodity sequence, but for continuously appearing commodities, it can be considered that the commodity is continuously browsed twice, and can be combined as one browsing action, for example, if the commodity sequence is “10022135513479, 10022135516179, 10020997382272, 10020997382272, 66265775344, 70445235238, 10020997382272, 10020997382273”, wherein each number sequence represents a commodity, and the number sequence “10020997382272” appears three times, of which two times are continuous, after deduplication, the commodity sequence becomes “10022135513479, 10022135516179, 10020997382272, 66265775344, 70445235238, 10020997382272, 10020997382273”.
[0053] S215, removing the commodity sequence whose length is less than or equal to 2.
[0054] According to an embodiment of the present disclosure, the commodity sequence whose length is less than or equal to 2 cannot extract a subsequence, and cannot extract more co-occurrence or co-value features except the commodities included in the sequence, and therefore is discarded.
[0055] Operation S220 includes operations S221-S226, and the specific process is as follows.
[0056] S221, sequentially taking each commodity in the commodity sequence as the center commodity, a subsequence of a preset length is intercepted from the commodity sequence.
[0057] According to an embodiment of the present disclosure, a subsequence of a preset length is intercepted from the commodity sequence sequentially taking each commodity in the commodity sequence as the center commodity, specifically, a sequence of a preset length is intercepted on the left and right sides of the center commodity to form a subsequence with the center commodity.
[0058] For example, for the commodity sequence "0022135513479, 10022135516179, 10020997382272, 66265775344, 70445235238, 10020997382272, 10020997382273", if the current center commodity is "66265775344", and a sequence of length 2 is intercepted on the left and right sides of the center commodity, the subsequence obtained is "10022135516179, 10020997382272, 66265775344, 70445235238, 10020997382272". The length intercepted on both sides of the center commodity can be adjusted according to actual conditions, and through experiments, the preferred length of interception is 5.
[0059] S222, counting the co-occurrence times of the center commodity and other commodities in the subsequence.
[0060] For example, if the subsequence is "10022135516179, 10020997382272, 66265775344, 70445235238, 10020997382272", and the center commodity is "66265775344", then the co-occurrence times of [66265775344, 10022135516179], [66265775344, 10020997382272], [66265775344, 70445235238], and [66265775344, 10020997382272] in the sequence are counted respectively.
[0061] S223, based on the co-occurrence times counted by each subsequence, counting the total co-occurrence times of each commodity and others.
[0062] For example, commodity A and commodity B co-occur 3 times in sequence 1 and 2 times in sequence 2, and sequence 1 and sequence 2 are all subsequences of the commodity sequence with commodity A as the center commodity, then the total co-occurrence times of commodity A and commodity B is 5.
[0063] S224, constructing a co-occurrence matrix based on the total co-occurrence times.
[0064] S225, counting the co-value number of attributes of each of the commodities and other commodities in the commodity sequence.
[0065] Suppose that the central commodity is a, one of the other commodities in the sub-sequence is b, and the attributes of commodity a and commodity b are as follows:
[0066] Item Brand Model Color Memory Screen Storage Release Time a Apple 11 Pro Black 128 LCD 1286 2019 b Huawei P40 Black 128 OLED 256G 2019
[0067] According to the table, the co-value attributes of commodity a and commodity b are "color", "memory", and "market time", i.e., the co-value number of attributes of commodity a and commodity b is 3.
[0068] S226, constructing a co-value matrix based on the co-value number.
[0069] According to embodiments of the present disclosure, the row index and column index of each element in the co-occurrence matrix and the co-value matrix respectively represent the serial number of one commodity in the commodity sequence, the element in the co-occurrence matrix represents the total co-occurrence times of two commodities in the commodity sequence, and the element in the co-value matrix represents the co-value number of two commodities in the commodity sequence.
[0070] According to embodiments of the present disclosure, each commodity in the commodity sequence is taken as a central commodity to obtain a sub-sequence, and the co-occurrence and co-value number of the central commodity and other commodities in each sub-sequence are counted, and finally the co-occurrence and co-value number between two commodities in the commodity sequence can be counted. Assuming that the number of commodities contained in the commodity sequence is n, the co-occurrence matrix and the co-value matrix of n*n size can be obtained, and the co-occurrence matrix and the co-value matrix are both symmetric matrices. The element in the i-th row and the j-th column of the co-occurrence matrix represents the co-occurrence times of the i-th commodity and the j-th commodity in the commodity sequence, and correspondingly, the element in the i-th row and the j-th column of the co-value matrix represents the co-value number of attributes of the i-th commodity and the j-th commodity in the commodity sequence.
[0071] According to embodiments of the present disclosure, the co-occurrence matrix represents the global information of the commodity sequence, and the co-value matrix represents the individual difference information of the commodity sequence. The co-occurrence matrix and the co-value matrix are weighted and fused to obtain a fusion matrix, and a commodity vectorization model considering globality and individual difference is constructed based on the fusion matrix, and the vector representation of the commodity is obtained by training the model.
[0072] Specifically, according to operation S230, the operation of obtaining the fusion matrix includes operations S231-S232.
[0073] S231, assigning a first weight to the co-occurrence matrix and a second weight to the co-value matrix, the sum of the first weight and the second weight being 1.
[0074] S232, obtaining a fusion matrix based on a sum of a product of the co-occurrence matrix and the first weight and a product of the co-value matrix and the second weight.
[0075] According to an embodiment of the present disclosure, let the co-occurrence matrix be X, the co-value matrix be V, and the fusion matrix be P, then:
[0076] P = βX + (1-β)V
[0077] wherein the parameter β is the first weight, (1-β) is the second weight, and β can be 0.4 after experiments.
[0078] According to an embodiment of the present disclosure, after obtaining the fusion matrix, a commercialization model can be constructed based on the fusion matrix, the commercialization model including a regression function, a weight function, and a regularization term, wherein the regression function is a function representing the relationship between the first vector and the second vector of a commodity, used to learn the first matrix and the second matrix, the weight function is a function representing the corresponding weight of each commodity, used to suppress the noise in the regression function, and the regularization term is used to prevent overfitting of the commodity vectorization model training.
[0079] In an embodiment of the present disclosure, the preset commodity vectorization model can include:
[0080]
[0081]
[0082] wherein J represents the commodity vectorization model, f(P ij ) represents the weight function with the element P ij of the fusion matrix P as input, i and j respectively represent the numbers of commodities, w i represents the first vector of the commodity i, represents the transpose of the first vector, w j represents the first vector of the commodity j, represents the second vector of the commodity j, b i represents the bias term of the first vector w i , represents the bias term of the second vector , V represents the number of P ij selected as input of the commercialization model, and α is an adjustment parameter.
[0083] According to the above commodity vectorization model, the regression function is:
[0084]
[0085] Wherein, the weight function f(Pij) has the following characteristics: it is monotonically increasing; its value range is between 0-1; f(0) = 0.
[0086] The main role of the weight function includes: the function will suppress the influence of the high value in the fusion matrix, and the secondary sampling, which plays a certain denoising function.
[0087] The value range of the weight function is a smooth curve between 0-1, which is much smaller than the statistical value, and can avoid the value of the fusion matrix being over-weighted. Through experiments, a can be taken as 0.2.
[0088] Unlike using neural networks to train parameters in Item2vec, here we use the regression method of the least square principle. Because the hidden layer in the Item2vec model does not use the activation function, it means that the learning of the hidden layer is actually a linear relationship when learning the commodity vector. We get inspiration from this to construct a function to fit the linear relationship, that is, to use a typical least square principle. In the formula, the parameter matrix w and is the commodity vector we require, P ij represents the value in the fusion matrix. b i and are the bias terms of the two parameter matrices, which play a regulating role.
[0089] The regularization term in the model is:
[0090] ρ(||w i || 2 +||w j || 2 ).
[0091] The last term of the function is the regularization term, and here we use the L2 norm of the parameter vector, the purpose of which is to prevent the model from overfitting during training, where ρ can be taken as 0.0005.
[0092] According to operation S240, the fusion matrix is input into the preset commodity vectorization model to obtain the vectors of each commodity, including steps S241-S244.
[0093] S241, randomly select a preset number of non-zero, non-diagonal elements from the fusion matrix, and input the elements into the commodity vectorization model.
[0094] According to embodiments of the present disclosure, the number of elements selected from the fusion matrix can be preset, or can be all non-zero, non-diagonal elements in the fusion matrix.
[0095] S242, the gradient descent algorithm is used to optimize the first matrix, the second matrix, the first bias term, and the second bias term in the commodity vectorization model.
[0096] After the elements of the fusion matrix are input into the model, the Adagrad gradient descent algorithm can be used to update the first matrix w and the second matrix of each commodity, so that the first vector wi and the second vector of each commodity are updated. The model also includes a bias term b i for the first vector and a bias term for the second vector, which are also updated using the same algorithm. When initialized, w and are random value matrices with a shape of (sku_size, embed_size), and b and are random value matrices with a shape of (sku_size, 1). Here, sku represents a commodity, sku_size represents the number of all skus, and embed_size represents the dimension of the obtained sku vector.
[0097] The formula for updating the model parameters (including the first vector, the second vector, and the bias terms corresponding to the first vector and the second vector) is as follows:
[0098]
[0099] where w t+1 and w t represent the parameter values at steps t and t+1 in the training process, g t represents the model gradient value calculated at step t. α represents the global learning rate, which is set to 0.05 here. δ is a smoothing term to prevent the divisor from being 0, which is taken as 1 e-8 here.
[0100] Because the vectorization of commodities is a typical sparse data scenario, the Adagrad algorithm is selected to update the gradient, because the Adagrad algorithm can make larger updates to low-frequency parameters and smaller updates to high-frequency parameters, so it performs better for sparse data. According to actual needs, other optimization algorithms can also be used to update the model parameters.
[0101] S243, repeat the above steps until the commodity vectorization model converges, obtaining the optimal first matrix and second matrix.
[0102] S244, obtain the first vector and the second vector of each commodity according to the first matrix and the second matrix, calculate the sum of the first vector and the second vector, and obtain the vector representation of the commodity.
[0103] After the training is completed through the above method, two parameter matrices w and Each row represents a vector representation of a corresponding commodity. According to the method of constructing the fusion matrix, the fusion matrix is symmetric, so theoretically deduce w and It should also be symmetric. Because the initialization is random, the final value is different. Therefore, in order to improve the robustness and expression ability, we finally calculate the sum of the two vectors as the final commodity vector, that is:
[0104] Figure 3 The flowchart of the commodity vectorization method according to the embodiment of the present disclosure is schematically shown.
[0105] As Figure 3 shown, session represents a commodity sequence, and sku represents a commodity in the commodity sequence. According to operations S221-S226, the co-occurrence matrix and the co-value matrix can be obtained. According to operations S231-S232, the co-occurrence matrix and the co-value matrix are fused to obtain a symmetric fusion matrix. The elements of the fusion matrix are input into the model to obtain the first vector and the second vector of the commodity. Finally, the first vector and the second vector are added to obtain the final vector representation of the commodity.
[0106] According to the embodiment of the present disclosure, after obtaining the fixed vector of each commodity, the similarity between commodities can be directly measured by calculating the distance of the vector.
[0107] Here we use the cosine distance, the formula is:
[0108]
[0109] Figure 4 The structural block diagram of commodity vectorization according to the embodiment of the present disclosure is schematically shown.
[0110] As Figure 4 shown, the commodity vectorization device 400 includes a commodity sequence generation module 410, a matrix data acquisition module 420, a matrix fusion module 430, and a vector generation module 440.
[0111] The commodity sequence generation module 410 is configured to generate at least one commodity sequence based on commodity browsing records in a preset time period.
[0112] The matrix data acquisition module 420 is configured to generate a co-occurrence matrix based on the co-occurrence times between different category commodities in the at least one commodity sequence, and generate a co-value matrix based on the co-value quantities of attributes between different category commodities in the at least one commodity sequence.
[0113] The matrix fusion module 430 is configured to fuse the co-occurrence matrix and the co-value matrix to obtain a fusion matrix.
[0114] The vector generation module 440 is used to input the fusion matrix into a preset product vectorization model to obtain vectors of each product.
[0115] The product sequence generation module 410 includes: a first preset duration determination unit 411 and a sequence segmentation unit 412 .
[0116] The first preset time determination unit 411 is used to determine whether the browsing interval between adjacent products in the product browsing record exceeds a first preset time;
[0117] The sequence segmentation unit 412 is used to divide the product browsing records into two segments based on the browsing interval when the browsing interval between two adjacent products exceeds a first preset time length, and generate a product sequence according to each segment of the product browsing record. The product sequence consists of products arranged in the browsing order.
[0118] The product sequence generation module 410 further includes: a second preset duration determination unit 413 , a duplicate removal unit 414 , and a sequence screening unit 415 .
[0119] The second preset time determination unit 413 is configured to remove products from the product sequence whose browsing time does not reach the second preset time.
[0120] The deduplication unit 414 is used to remove duplicates of the same product that appear continuously in the product sequence.
[0121] The sequence screening unit 415 is used to remove product sequences whose length is less than or equal to 2.
[0122] The matrix data acquisition module 420 includes: a subsequence generating unit 421 , a subsequence counting unit 422 , and a total number counting unit 423 .
[0123] The subsequence generating unit 421 is configured to sequentially use each product in the product sequence as a central product and extract a subsequence of a preset length from the product sequence.
[0124] The subsequence counting unit 422 is used to count the number of co-occurrences between the central product and other products in the subsequence, and to count the number of co-values of the attributes of the central product and other products in the subsequence.
[0125] A total number counting unit 423 is used to count the total number of co-occurrences and the total number of co-values between each product in the product sequence based on the co-occurrence times and co-value numbers counted in each subsequence;
[0126] A co-occurrence matrix is constructed based on the total number of co-occurrences, and a co-value matrix is constructed based on the total number of co-values.
[0127] Wherein, the row index and the column index of each element in the co-occurrence matrix and the co-value matrix represent the serial number of a commodity in the commodity sequence, the element in the co-occurrence matrix represents the total number of co-occurrences of two commodities in the commodity sequence, and the element in the co-value matrix represents the total number of co-values of two commodities in the commodity sequence.
[0128] The matrix fusion module 430 comprises a weight distribution unit 431 and a fusion calculation unit 432.
[0129] The weight distribution unit 431 is configured to assign a first weight to the co-occurrence matrix and a second weight to the co-value matrix, and the sum of the first weight and the second weight is 1.
[0130] The fusion calculation unit 432 is configured to calculate the product of the co-occurrence matrix and the first weight, the product of the co-value matrix and the second weight, sum the products, and obtain a fusion matrix.
[0131] The vector generation module 440 comprises an input unit 441, an optimization unit 442, a control unit 443, and a vector summation unit 444.
[0132] The input unit 441 is configured to randomly select a random number of non-zero, non-diagonal elements from the fusion matrix and input the elements into the commodity vectorization model.
[0133] The optimization unit 442 is configured to train the first matrix and the second matrix in the commodity vectorization model by using a gradient descent algorithm.
[0134] The control unit 443 is configured to repeat the above steps until the gradient descent algorithm converges, and obtain the optimal first matrix and the optimal second matrix.
[0135] The vector summation unit 444 is configured to obtain a first vector and a second vector of each commodity according to the first matrix and the second matrix, calculate the sum of the first vector and the second vector, and obtain the vector representation of the commodity.
[0136] Any of the modules, sub-modules, units, sub-units, or at least part of any of them according to embodiments of the present disclosure can be implemented in one module. Any of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure can be split into multiple modules for implementation. Any of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure can be implemented at least in part as a hardware circuit, for example, a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on board, a system on package, an application specific integrated circuit (ASIC), or any other reasonable way of hardware or firmware by integrating or packaging circuits, or in any one of software, hardware, and firmware, or in a proper combination of any of them. Alternatively, any of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure can be implemented at least in part as computer program modules, which can perform corresponding functions when running.
[0137] For example, any of the commodity sequence generation module 410, the matrix data acquisition module 420, the matrix fusion module 430, and the vector generation module 440 can be combined in one module / unit / sub-unit for implementation, or any of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more of the modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units, and implemented in one module / unit / sub-unit. According to embodiments of the present disclosure, at least one of the commodity sequence generation module 410, the matrix data acquisition module 420, the matrix fusion module 430, and the vector generation module 440 can be implemented at least in part as a hardware circuit, for example, a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on board, a system on package, an application specific integrated circuit (ASIC), or any other reasonable way of hardware or firmware by integrating or packaging circuits, or in any one of software, hardware, and firmware, or in a proper combination of any of them. Alternatively, at least one of the commodity sequence generation module 410, the matrix data acquisition module 420, the matrix fusion module 430, and the vector generation module 440 can be implemented at least in part as computer program modules, which can perform corresponding functions when running.
[0138] It should be noted that the commodity vectorization device part in embodiments of the present disclosure corresponds to the commodity vectorization method part in embodiments of the present disclosure, and the description of the commodity vectorization device part is specifically referred to the commodity vectorization method part, which will not be repeated here.
[0139] Figure 5 A block diagram of a computer system suitable for implementing the above-described methods according to embodiments of the present disclosure is shown schematically. Figure 5 The computer system shown is merely one example. It should not be considered a limitation on the functioning and usefulness of embodiments of the present disclosure.
[0140] As Figure 5 shown, a computer system 500 according to embodiments of the present disclosure includes a processor 501 which can perform various appropriate actions and processes in accordance with programs stored in a read only memory (ROM) 502 or loaded into a random access memory (RAM) 503 from a storage section 508. The processor 501 can include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor, and / or a related chip set and / or a dedicated microprocessor (e.g., an application specific integrated circuit (ASIC)), and so on. The processor 501 can also include an on-board memory for cache use. The processor 501 can include a single processing unit or multiple processing units to perform the different actions of the method processes according to embodiments of the present disclosure.
[0141] In the RAM 503, various programs and data required for the operation of the system 500 are stored. The processor 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. The processor 501 performs various operations of the method processes according to embodiments of the present disclosure by executing the programs in the ROM 502 and / or the RAM 503. Note that the programs can also be stored in one or more memories other than the ROM 502 and the RAM 503. The processor 501 can also perform various operations of the method processes according to embodiments of the present disclosure by executing the programs stored in the one or more memories.
[0142] According to embodiments of the present disclosure, the system 500 can also include an input / output (I / O) interface 505 which is also connected to the bus 504. The system 500 can further include one or more of the following components connected to the I / O interface 505: an input section 506 including input devices such as a keyboard and mouse; an output section 507 including output devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as necessary. A removable recording medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 510 as necessary, so that a computer program read therefrom is installed into the storage section 508 as necessary.
[0143] According to an embodiment of the present disclosure, the method flow according to the embodiments of the present disclosure can be implemented as a computer software program. For example, the embodiments of the present disclosure include a computer program product comprising a computer program carrying out the method shown in the flow chart, which is embodied on a computer readable storage medium. In such an embodiment, the computer program can be downloaded and installed from a network by the communication section 509, and / or installed from the detachable medium 511. When the computer program is executed by the processor 501, the above-mentioned functions defined in the system implementing the embodiments of the present disclosure are executed. According to an embodiment of the present disclosure, the system, device, apparatus, module, unit, etc. described above can be implemented by computer program modules.
[0144] The present disclosure also provides a computer readable storage medium, which can be included in the device / apparatus / system described in the above embodiments, or can exist separately without being assembled into the device / apparatus / system. The above computer readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of the present disclosure.
[0145] According to an embodiment of the present disclosure, the computer readable storage medium can be a non-volatile computer readable storage medium. For example, it can include but is not limited to: a portable computer diskette, a hard disk, a random access memory (RAM), a read only memory (ROM), an erasable programmable read only memory (EPROM or flash memory), a portable compact disc read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any appropriate combination thereof. In the present disclosure, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus or device.
[0146] For example, according to an embodiment of the present disclosure, the computer readable storage medium can include one or more memories other than the ROM 502 and / or the RAM 503 and / or the ROM 502 and the RAM 503 described above.
[0147] The computer program product of the first aspect can include one or more non-transitory computer-readable media storing instructions that, when executed, cause one or more processors to perform the operations of the first aspect. The one or more non-transitory computer-readable media can include, for example, magnetic media such as one or more magnetic disks, magnetic tapes or cassettes; optical media such as one or more compact discs (CD), optical discs or discs (for example, DVD, Blu-ray Disc®, digital video disc, ultra density disc, ultra-compact disc, any optical media, etc.); semiconductor media such as solid state hard drives (for example, flash memory, solid state USB drives, etc.); any other suitable medium; or any suitable combination of media.
[0148] Those skilled in the art will understand that features of the various embodiments and / or claims of the present disclosure can be combined and / or sub-combined, even if such combinations or sub-combinations are not expressly noted in the present disclosure. In particular, features of the various embodiments and / or claims of the present disclosure can be combined and / or sub-combined in any number of ways, without departing from the spirit and scope of the present disclosure. All such combinations and / or sub-combinations are within the scope of the present disclosure.
[0149] The above describes embodiments of the present disclosure. However, these embodiments are merely for illustrative purposes, and are not intended to limit the scope of the present disclosure. Although the above describes each embodiment separately, this does not mean that the measures in each embodiment cannot be used advantageously in combination. The scope of the present disclosure is defined by the appended claims and their equivalents. Those skilled in the art can make various substitutions and modifications without departing from the scope of the present disclosure, and all such substitutions and modifications shall fall within the scope of the present disclosure.
Claims
1. A commodity vectorization method, comprising: generating at least one commodity sequence based on commodity browsing records within a preset time period; generating a co-occurrence matrix based on a co-occurrence number between different commodity categories in the at least one commodity sequence, and generating a co-value matrix based on a co-value number between attributes of different commodity categories in the at least one commodity sequence; fusing the co-occurrence matrix and the co-value matrix to obtain a fusion matrix; inputting the fusion matrix into a preset commodity vectorization model and optimizing the commodity vectorization model to obtain a vector representation of each commodity; wherein parameters of the commodity vectorization model at least include a first matrix, a second matrix and the fusion matrix, each row vector of the first matrix represents a first vector of one commodity, each row vector of the second matrix represents a second vector of one commodity, and the first vector and the second vector jointly constitute a vector representation of the corresponding commodity, and the commodity vectorization model is optimized to obtain an optimal vector representation of each commodity.
2. The method of claim 1, wherein, The generating of the at least one commodity sequence based on the commodity browsing records within the preset time period comprises: determining whether a browsing interval between each adjacent commodity in the commodity browsing records exceeds a first preset time length; when the browsing interval between two adjacent commodities exceeds the first preset time length, dividing the commodity browsing records into two segments with the browsing interval as a division point, and generating a commodity sequence according to each segment of the commodity browsing records, the commodity sequence being composed of commodities arranged in a browsing order. 3.The method of claim 2, further comprising: removing commodities in the commodity sequence whose browsing time length does not reach a second preset time length; de-duplicating a same commodity continuously appearing in the commodity sequence; and removing the commodity sequence whose length is less than or equal to 2. The generating of the co-occurrence matrix based on the co-occurrence number between different commodity categories in the at least one commodity sequence, and the generating of the co-value matrix based on the co-value number between attributes of different commodity categories in the at least one commodity sequence comprise:
4. The method of claim 1, wherein, sequentially taking each commodity in the commodity sequence as a center commodity to intercept a sub-sequence of a preset length from the commodity sequence; counting a co-occurrence number of the center commodity and other commodities in the sub-sequence; counting a total co-occurrence number of each commodity and other commodities based on the co-occurrence number counted by each sub-sequence; constructing the co-occurrence matrix based on the total co-occurrence number; and counting a co-value number of each commodity and attributes of other commodities in the commodity sequence in the commodity sequence; constructing the co-value matrix based on the co-value number. Row indices and column indices of each element in the co-occurrence matrix and the co-value matrix represent serial numbers of one commodity in the commodity sequence, the element in the co-occurrence matrix represents a total co-occurrence number of two commodities in the commodity sequence, and the element in the co-value matrix represents a co-value number of two commodities in the commodity sequence.
5. The method of claim 4, wherein, 6. The method of claim 1, wherein the fusing the co-occurrence matrix and the co-value matrix with weights to obtain a fused matrix comprises: assigning a first weight to the co-occurrence matrix and a second weight to the co-value matrix, wherein the first weight and the second weight sum to 1; computing a product of the co-occurrence matrix and the first weight, a product of the co-value matrix and the second weight, and summing the products to obtain the fused matrix.
7. The method of claim 1, the item vectorization model comprising a regression function, a weight function, and a regularization term, wherein, The regression function is a function representing the relationship between the first vector and the second vector of the commodity, used to learn the first matrix and the second matrix, and the weight function is a function of the regression function representing the corresponding weight of each commodity, used to suppress the noise in the regression function, and the regularization term is used to prevent the commodity vectorization model from overfitting.
8. The method of claim 7, wherein the inputting the fused matrix into a preset commodity vectorization model and optimizing the commodity vectorization model to obtain a vector representation of each commodity comprises: randomly selecting a preset number of non-zero, non-diagonal elements from the fused matrix and inputting the elements into the commodity vectorization model; training the first matrix, the second matrix, the first bias term, and the second bias term in the commodity vectorization model using a gradient descent algorithm; repeating the above steps until the commodity vectorization model converges to obtain optimal first and second matrices; obtaining a first vector and a second vector of each commodity according to the first matrix and the second matrix, and calculating the sum of the first vector and the second vector to obtain the vector representation of the corresponding commodity.
9. A commodity vectorization device, comprising: a commodity sequence generation module configured to generate at least one commodity sequence based on commodity browsing records within a preset time period; a matrix data acquisition module configured to generate a co-occurrence matrix based on the number of co-occurrences between different category commodities in the at least one commodity sequence, and generate a co-value matrix based on the number of co-values of attributes between different category commodities in the at least one commodity sequence; a matrix fusion module configured to fuse the co-occurrence matrix and the co-value matrix with weights to obtain a fused matrix; a vector generation module configured to input the fused matrix into a preset commodity vectorization model and optimize the commodity vectorization model to obtain a vector of each commodity; wherein the parameters of the commodity vectorization model include at least a first matrix and a second matrix and the fused matrix, each row vector of the first matrix is a first vector of a commodity, each row vector of the second matrix is a second vector of a commodity, and the first vector and the second vector together constitute a vector representation of the corresponding commodity, and the commodity vectorization model is optimized to obtain an optimal vector representation of each commodity.
10. A computer system, comprising: one or more processors; a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to carry out the method of any one of claims 1 to 8.
11. A computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to carry out the method of any one of claims 1 to 8.
Citation Information
Patent Citations
A word vector representation learning method based on word pair asymmetric co-occurrence
CN109670171A
Commodity matching recommendation method and device based on attributes and titles
CN111507812A