COMBINED COMMODITY MINING METHOD BASED ON KNOWLEDGE GRAPH RULE EMBEDDING
20230041927 · 2023-02-09
Inventors
- HUAJUN CHEN (HANGZHOU, ZHEJIANG PROVINCE, CN)
- WEN ZHANG (HANGZHOU, ZHEJIANG PROVINCE, CN)
- JIAOJIAN KANG (HANGZHOU, ZHEJIANG PROVINCE, CN)
Cpc classification
G06F18/21326
PHYSICS
G06N3/042
PHYSICS
International classification
Abstract
The present invention is a combined commodity mining method based on knowledge graph rule embedding, comprising: expressing rules, commodities, attributes, and attribute values as embeddings; splicing and inputting the embeddings of the rules and the embeddings of the attributes into a first neural network to obtain a importance scores of the attributes; splicing and inputting the rules and attributes into a second neural network to obtain the embeddings of the attribute values that the rules should take under the attributes; calculating a similarity between the value of two inputted commodities under the attribute and the embedding of the attribute value calculated by a model; after calculating scores of all attribute-attribute value pairs, summing up to obtain scores of these two commodities under this rule; then making the cross entropy loss with the real scores of these two commodities, and iteratively training based on an optimization algorithm having gradient descent; after the model is trained, parsing the embeddings of the rules in a similar way to obtain rules that can be understood by human beings.
Claims
1. A combined commodity mining method based on knowledge graph rule embeddings, comprising: (1) constructing a knowledge graph of commodities, wherein for each ternary group data in the knowledge graph, a head entity is a commodity I, a relation is a commodity attribute P, a tail entity is a commodity attribute value V; (2) expressing the commodity I, commodity attribute P, and commodity attribute value V as embeddings, respectively, and randomly initializing the embeddings of a plurality of rules; (3) splicing and inputting the embedding of each rule and the embedding of each commodity attribute into a first neural network to obtain a importance scores.sub.1 of the commodity attribute; (4) splicing and inputting the embedding of each rule and the embedding of each commodity attribute into a second neural network to obtain the embedding of the attribute value that the rule should obtain under that attribute; V.sub.pred; (5) splicing and inputting the embedding of each rule and the embedding of each commodity attribute into a third neural network, and calculating a probability score p of the same attribute value of a certain attribute under a certain rule; (6) if attribute values of two commodities under a certain attribute are different, calculating a similarity score S.sub.21 of V.sub.pred and V.sub.1, and a similarity score S.sub.22 of V.sub.pred and V.sub.2; and if the attribute values of two commodities under the certain attribute are the same, calculating a similarity score S.sub.2 of the V.sub.pred and V.sub.true; wherein, V.sub.1 represents an embedding of an attribute value of one of the two commodities under the attribute, V.sub.2 is an embedding of an attribute value of another commodity under the attribute, V.sub.ture is an embedding of the same attribute value; (7) when an importance score s.sub.1 of a certain attribute is greater than a threshold thres.sub.1, and the attribute values of the two commodities are the same under the certain attribute, summing up to obtain a score.sub.ij of this attribute-attribute value pair as s.sub.1×(p+(1-p )×s.sub.2); when the importance score s.sub.1 of a certain attribute is greater than the thres.sub.1, and the attribute values of the two commodities under the certain attribute are different, summing up to obtain the score.sub.ij of this attribute-attribute value pair as 0.5×s.sub.1×(s.sub.1×(s.sub.21+ s.sub.22); when the importance score s.sub.1 of a certain attribute is less than or equal to the thres.sub.1, taking the score of this attribute-attribute value pair as 0; (8) summing up the scores “score.sub.ij” of m attribute-attribute value pairs of a commodity pair to obtain score.sub.i:
2. The combined commodity mining method based on knowledge graph rule embedding according to claim 1, wherein, in step (2), the commodity I, the commodity attribute P, the commodity attribute value V and a plurality of rules are respectively numbered as ids, and then each of the ids constitutes a one-hot vector, and then the one-hot vector is mapped into an embedding, which is continuously optimized with a model training process.
3. The combined commodity mining method based on knowledge graph rule embedding according to claim 1, wherein, in steps (3) to (5), in the three neural networks, a calculation formula of an activation function of each layer of neurons is:
4. The combined commodity mining method based on knowledge graph rule embedding according to claim 1, wherein, in steps (3) to (5), in the three neural networks, a calculation formula of each layer of each neural network is:
5. The combined commodity mining method based on knowledge graph rule embedding according to claim 1, wherein, in step (6), the similarity scores s.sub.21, s.sub.22 and s.sub.2 are all calculated by cosine similarity, and the specific formulas are:
6. The combined commodity mining method based on knowledge graph rule embedding according to claim 1, wherein, in step (10), the cross entropy loss function is:
7. The combined commodity mining method based on knowledge graph rule embedding according to claim 1, wherein, in step (10), the optimization algorithm having the gradient descent is SGD or Adam.
8. The combined commodity mining method based on knowledge graph rule embedding according to claim 1, wherein, the specific process of step (11) is: for the learned rule embedding and each commodity pair, splicing and inputting the rule embedding and the embedding of each attribute of the commodity pair into the first network to obtain the importance score of each attribute; if the importance score s.sub.1 of the attribute is greater than the threshold thres.sub.1, then including the attribute in this rule; if the attribute is comprised in this rule, and the attribute values of the two commodities under this attribute are the same, calculating a probability p of taking “same” under this attribute; if p is greater than the threshold thres.sub.2, then taking the values under this attribute as the same; if p is less than or equal to the threshold thres.sub.2, then calculating the similarity score s.sub.2 of the two commodities under this attribute; if s.sub.2 is greater than the threshold thres.sub.3, then taking, by the rule, the attribute value shared by the two commodities under this attribute; if the attribute is comprised in this rule, and the attribute values of the two commodities under this attribute are not the same, then calculating the similarity scores s.sub.11 and s.sub.12, if both s11 and s12 are greater than the threshold thres.sub.3, then taking, by the rule, the two attribute values of these two commodities under this attribute.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0037]
DETAILED DESCRIPTION OF THE EMBODIMENTS
[0038] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be pointed out that the following embodiments are intended to facilitate the understanding of the present invention, but do not have any limiting effect on it.
[0039] As shown in
[0040] S01. constructing a knowledge graph of commodities, wherein for each ternary group, a head entity is a commodity, a relation is a commodity attribute, a tail entity is a commodity attribute value. A task of combining commodities is defined as: given two commodities in the commodity knowledge graph, and a plurality of attributes and attribute values of each commodity, it is necessary to determine whether the two commodities are a combined commodity. The innovation of the present invention is that rule learning is integrated into a model training process, so that a seller can be provided with interpretability through learned rules.
[0041] S02. expressing firstly each commodity, commodity attribute, commodity attribute value, and rule as an id, and then indexing each id to an embedding. For each sample, the inputted two commodities would have n attributes and attribute values, plus the inputted n rules, the present invention predicts whether the two commodities are a combined commodity based on this method.
[0042] S03. calculating firstly a score of each attribute. Firstly, splicing and inputting the embedding of each rule and the embedding of each commodity attribute into a first neural network to obtain a importance score s.sub.1 of the attribute. A formula for each layer of the first neural network is:
[0043] Specifically, by splicing and inputting the embedding of each rule and the embedding of the commodity attribute into a fully connected layer, more and more high-level semantics are obtained, and finally the importance score s.sub.1 of the attribute under the rule can be predicted based on the high-level semantics, a larger value means that the attribute is more likely to be included in this rule. Pre-setting a threshold thres.sub.1, when the value of s.sub.1 is greater than thres.sub.1, then the attribute is included in this rule.
[0044] S04. then calculating a score of each attribute value. Splicing and inputting the embedding of each rule and the embedding of each commodity attribute into a second neural network to obtain a predicted embedding of the attribute value. A formula for each layer of the second neural network is:
[0045] Specifically, the rules and attributes can be inputted into a multi-layer neural network, and finally the embedding of the attribute value that should be taken under the attributes is predicted. Next, there are two cases. If the inputted attribute values under the attribute of the two commodities are the same, then a similarity between the attribute value and the predicted attribute value can be calculated. The higher the similarity degree, the higher the score of the attribute value. The method for calculating the similarity of the attribute value is as follows:
[0046] Meanwhile, there is a possibility that under this rule, the value under this attribute is “same”. At this time, splicing and inputting the embedding of each rule and the embedding of each commodity attribute into a third neural network, so as to obtain a probability that the value under this attribute is “same”. The formula of the third neural network is:
.Math.
[0047] If the inputted attribute values under the attribute of the two commodities are different, then the degree of similarity between the two attribute values and the predicted attribute values can be calculated separately, and then the two similarity scores can be combined to finally obtain the score for the two attribute values. The method for calculating the similarity of the attribute values is as follows:
[0048] S05. next, solving a score of an attribute-attribute value pair. It can be divided into three cases: when the score s.sub.1 of the attribute is less than or equal to the preset threshold thres.sub.1, then the score of the attribute value under the attribute should be 0; if the score s.sub.1 of the attribute is greater than the preset threshold thres.sub.1 and the attribute values of the two commodities under this attribute are the same, then the score of this attribute-attribute value is
[0049] if the score s.sub.1 of the attribute is greater than the preset threshold thres.sub.1 and the attribute values of the two commodities under this attribute are different, then the score of this attribute-attribute value is
[0050] S06, after obtaining the score of an attribute-attribute pair, calculating a score of a commodity pair under a certain rule, wherein the calculation formula is:
[0051] S07. after obtaining the score of a commodity pair under a certain rule, summing up the scores of the commodity pair under all the rules to obtain a final score of the commodity pair, wherein the calculation formula is:
[0052] S08. comparing the obtained score of the commodity pair with two labels 0 or 1 indicating whether belonging to a combined commodity to obtain a cross entropy loss;
[0053] This loss function is then optimized with the an Adam optimizer.
[0054] S09. after the rules are learned, parsing the rules, wherein the way of parsing the rules is similar to that during the training. First, the embedding of the rule and the embedding of each possible attribute are spliced and inputted into the first network to obtain the importance score of each attribute, and if the score s.sub.1 of the attribute is greater than the threshold thres.sub.1, then this attribute is included in this rule. Then, if the attribute is included in this rule, the value under the rule should be calculated to be “same” or a specific value.
[0055] In this way, the combination commodity rules can be obtained. In the final application, there are mainly two ways: [0056] The first way or method is as follows: [0057] Given a commodity pair, and the respective attributes and attribute values of each commodity, inputting this information into the model, you can get the probability score that two commodities in this commodity pair can be combined into a combined commodity, if the score is greater than 0.5, it is considered that these two commodities is a combined commodity. [0058] The second way or method is as follows: [0059] Given a commodity pair, and respective attributes and attribute values of each commodity. For all the rules generated by the present invention, check one by one to see whether each attribute-attribute value pair conforms to the current rule, and all attribute-attribute value pairs conform to the current rule, then based on the current rule, it can be determined that the two
[0060] commodities belong to a combined commodity. If none of the rules can determine that the two commodities belong to a combined commodity, then the two commodities do not constitute a combined commodity.
[0061] Next, a specific example is used to illustrate the construction process of the present invention.
[0062] First, as shown in Table 1, it is a sample of the model input, which contains two commodities, each commodity contains a plurality of attributes and attribute values, under each attribute, the attribute values of the two commodities may or may not be the same.
TABLE-US-00001 Commodity 1 Commodity 2 Brand Estee Lauder Estee Lauder Production Place Jiangsu Province Guangdong Province Effects Whitening Moisturizing Series Whitening cream Essence lotion Whether being a combined commodity Yes
[0063] First, representing all attributes and attribute values of the two commodities as embeddings. Then passing each attribute through the first neural network to obtain the importance score of the attribute; then inputting the attribute value to the second neural network to obtain the attribute value score. Then, summing up the attribute and attribute-value scores to obtain the attribute-attribute value pair score. Then, summing up the scores of all attribute-attribute value pairs to obtain the score of the two commodities belonging to the same commodity under this rule. Finally, summing up the scores of all the rules for these two commodities, and finally obtaining the score that these two commodities belong to the same commodity.
[0064] During the testing phase, the rules need to be parsed. As shown in Table 2, it is a rule parsed by the model based on the samples shown in Table 1.
TABLE-US-00002 Head Body Combination (Effects, whitening, moisturizing) && (Brand, same)
[0065] The way of parsing the rule is similar to that in the training process. It also determines which attributes the rule contains, and then determines which attribute values should be contained under each attribute, and finally the rule can be parsed.
[0066] The above-mentioned embodiments describe the technical solutions and beneficial effects of the present invention in detail. It should be understood that the above-mentioned embodiments are only specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, additions and equivalent replacements made within the principle of the present invention shall be included within the protection scope of the present invention.