Methods, apparatus and computer devices for constructing vectors for target objects
By mapping the historical selection data of the target object to a sparse vector through sparse coding, the vector of the target object is constructed, which solves the problem of dimensionality interference and improves the accuracy of vector construction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2021-11-13
- Publication Date
- 2026-05-26
AI Technical Summary
Existing techniques are prone to dimensional interference when constructing target object vectors, resulting in the generation of incorrect vectors and affecting the accuracy of vector construction.
By using sparse coding, the historical selection data of the target object is mapped to a sparse vector, and the vector of the target object is constructed based on the sparse vector, thereby achieving decoupling of each dimension of the vector.
It effectively avoids errors caused by the interaction of various dimensions during vector aggregation, thus improving the accuracy of vector construction.
Smart Images

Figure CN116150462B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for constructing vectors for a target object. Background Technology
[0002] With the development of artificial intelligence and big data technologies, user profiling technology has emerged. User profiling, also known as user personas, is an effective tool for outlining target users and connecting user needs with design direction, and it has been widely applied in various fields. In user profiling, the use of vectors to characterize user interests has become increasingly common. Vectorizing users as target objects is an important means of characterizing them, as vectorization can effectively quantify interpretable information (such as interests and habits) and some non-interpretable information about users.
[0003] Currently, when vectorizing target objects, the common approach is to first generate item vectors, and then combine them with the items clicked by the target object to obtain the target object's corresponding vector. A simple method is to calculate the mean or a weighted sum, while a more complex method involves fitting a network to balance the distances to each clicked item in the learned vector. However, this method is prone to dimensionality interference during vector construction, causing the balanced vector to be closer to items the target object is not interested in, resulting in incorrect vectors. Summary of the Invention
[0004] Therefore, it is necessary to provide a vector construction method, apparatus, computer device, computer-readable storage medium, and computer program product for the target object that can guarantee the accuracy of vector construction, in order to address the above-mentioned technical problems.
[0005] Firstly, this application provides a method for constructing a vector for a target object. The method includes:
[0006] Obtain historical selection data for the target object;
[0007] The selection targets in the historical selection data are mapped to sparse vectors through sparse coding.
[0008] Based on the sparse vector corresponding to the selected target, construct the vector corresponding to the target object.
[0009] Secondly, this application also provides a vector construction apparatus for a target object. The apparatus includes:
[0010] The data acquisition module is used to acquire historical selection data of the target object;
[0011] The vector mapping module is used to map the selection target in the historical selection data into a sparse vector through sparse coding.
[0012] The vector construction module is used to construct the vector corresponding to the target object based on the sparse vector corresponding to the selected target.
[0013] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0014] Obtain historical selection data for the target object;
[0015] The selection targets in the historical selection data are mapped to sparse vectors through sparse coding.
[0016] Based on the sparse vector corresponding to the selected target, construct the vector corresponding to the target object.
[0017] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0018] Obtain historical selection data for the target object;
[0019] The selection targets in the historical selection data are mapped to sparse vectors through sparse coding.
[0020] Based on the sparse vector corresponding to the selected target, construct the vector corresponding to the target object.
[0021] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0022] Obtain historical selection data for the target object;
[0023] The selection targets in the historical selection data are mapped to sparse vectors through sparse coding.
[0024] Based on the sparse vector corresponding to the selected target, construct the vector corresponding to the target object.
[0025] The aforementioned method, apparatus, computer device, storage medium, and computer program product for constructing vectors for target objects involve: acquiring historical selection data of the target object; mapping the selection targets in the historical selection data to sparse vectors through sparse coding; and constructing a vector corresponding to the target object based on the sparse vectors corresponding to the selection targets. This application achieves decoupling of the various dimensions of the vector by converting the selection targets in the historical selection data of the target object into sparse vectors before constructing the vector corresponding to the target object. This avoids errors caused by mutual influence between dimensions during vector aggregation, thus effectively ensuring the accuracy of vector construction. Attached Figure Description
[0026] Figure 1 This is an application environment diagram of a vector construction method for a target object in one embodiment;
[0027] Figure 2 This is a flowchart illustrating a vector construction method for a target object in one embodiment;
[0028] Figure 3 This is a flowchart illustrating the steps for obtaining the sparse vector corresponding to the selected target in one embodiment.
[0029] Figure 4 This is a schematic diagram of the steps for obtaining the item vector corresponding to the selected target in one embodiment;
[0030] Figure 5 This is a flowchart illustrating the steps for obtaining the cross-entropy error and mean squared error corresponding to the model training vectors in one embodiment.
[0031] Figure 6 This is a schematic diagram of the steps for obtaining training encoding vectors based on the square operation in one embodiment;
[0032] Figure 7 This is a flowchart illustrating a complete model training process in one embodiment.
[0033] Figure 8 This is a schematic diagram of the steps to construct the vector corresponding to the target object in one embodiment;
[0034] Figure 9 This is a flowchart illustrating a vector construction method for a target object in another embodiment;
[0035] Figure 10 This is a structural block diagram of a vector construction device for a target object in one embodiment;
[0036] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0037] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0038] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0039] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0040] The solutions provided in this application relate to the field of Machine Learning (ML) in artificial intelligence. Machine learning is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, and many other disciplines. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to enable computers to possess intelligence; its applications span all areas of artificial intelligence. Specifically, the solution in this application relates to the deep learning component of machine learning. Deep learning learns the inherent patterns and representational layers of sample data. The information obtained during this learning process greatly helps in interpreting data such as text, images, and sound. Its ultimate goal is to enable machines to have analytical learning capabilities like humans, and to recognize data such as text, images, and sound. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instructional learning. This application mainly uses deep learning technology to perform object vectorization processing. Vectorization, or embedding, specifically refers to representing an object using a multi-dimensional vector, thereby mapping the object to a point in a multi-dimensional space. Vectorization allows for the effective quantification of objects, and the relationships between objects can be transformed into relationships between vectors. This application also relates to Word2vec, a method for vectorizing words. After vectorization, the semantic relevance between words can be converted into the distance between vectors, i.e., the distance between two points in the vector space. The solution of this application is specifically illustrated through the following embodiments:
[0041] The vector construction method for target objects provided in this application can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. The terminal can submit historical selection data of a target object to server 104 to construct a vector corresponding to the target object. Server 104 obtains the historical selection data of the target object; maps the selection target in the historical selection data to a sparse vector through sparse coding; and constructs the vector corresponding to the target object based on the sparse vector corresponding to the selection target. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster composed of multiple servers.
[0042] In one embodiment, such as Figure 2 As shown, a method for constructing vectors for a target object is provided, which can be applied to... Figure 1 Taking server 104 as an example, the following steps are included:
[0043] Step 201: Obtain historical selection data for the target object.
[0044] Historical selection data refers to content selection data related to the target object. Specifically, it can include item data selected by the target object when using terminal 102, including items selected by the target object through clicking, voice selection, and batch selection by the target object through selection. Terminal 102 has network connectivity. With the target object's permission, it can record the target object's historical selection data when the target object browses web pages or products through the application on terminal 102, determining the specific content of the web pages or items browsed by the target object, thus forming the basic data for vector construction. This data is then sent to a remote server 104 to construct vectors based on the target object's historical selection data.
[0045] Specifically, when constructing the vector corresponding to the target object, it is necessary to base it on the target object's historical selection data, which can characterize the target object's interests to a certain extent. When obtaining the target object's historical selection data, a time limit can be set to obtain only the target object's historical selection data within a recent period, using it as the basis for vector construction. This makes the constructed vector more closely reflect the target object's recent interests and improves the accuracy of vector construction.
[0046] Step 203: Map the selection targets in the historical selection data into sparse vectors through sparse coding.
[0047] Sparse coding is an unsupervised learning method used to find a set of "overcomplete" basis vectors to more efficiently represent sample data. The goal of sparse coding is to find a set of basis vectors such that the input vector can be represented as a linear combination of these basis vectors. The selection target in the historical selection data can specifically be the item vector corresponding to that target, which is a densely encoded vector. Sparse coding maps the densely encoded item vector to a sparse vector.
[0048] Specifically, when constructing a vector for a target object, it is generally necessary to aggregate multiple different items corresponding to the target object as the base data of the vector. However, during the vector aggregation process, the interaction of different dimensions can easily lead to errors in the resulting vector. Therefore, this application first decouples the various dimensions of the vector by performing sparse encoding on the item vectors selected from the historical selection data. Then, these sparse vectors are aggregated into the vector corresponding to the target object, avoiding errors caused by the interaction of different dimensions during the aggregation process. Thus, after obtaining the historical selection data, sparse encoding can be used to map the selected targets in the historical selection data to the corresponding sparse vectors.
[0049] Step 205: Construct the vector corresponding to the target object based on the sparse vector corresponding to the selected target.
[0050] In this embodiment, the vector corresponding to the target object refers to a method in machine learning, such as deep learning, of characterizing the target object's interests through data vectorization, thereby achieving user profiling. Vectorization specifically refers to representing an object using a multi-dimensional vector, thus mapping the object to a point in a multi-dimensional space. The result of vectorization is that objects are effectively quantified, and the relationships between objects can be transformed into relationships between vectors.
[0051] Specifically, after sparsely encoding the selected targets corresponding to the target, the sparse vectors corresponding to different selected targets have been decoupled. At this point, the sparse vectors corresponding to all the selected targets of the target object can be aggregated to construct the vector corresponding to the target object, thereby avoiding the mutual influence of various dimensions during the vector aggregation process and ensuring the effectiveness of the vector construction for the target object.
[0052] The aforementioned vector construction method for target objects involves obtaining historical selection data of the target object; mapping the selection targets in the historical selection data to sparse vectors through sparse encoding; and constructing the vector corresponding to the target object based on the sparse vectors corresponding to the selection targets. This application, by transforming the selection targets in the historical selection data of the target object into sparse vectors before constructing the vector corresponding to the target object, achieves decoupling of the various dimensions of the vector, avoiding errors caused by mutual influence between dimensions during vector aggregation, and thus effectively ensuring the accuracy of vector construction.
[0053] In one embodiment, such as Figure 3 As shown, step 203 includes:
[0054] Step 302: Obtain the item vector corresponding to the selected target in the historical selection data.
[0055] Step 304: Sparsely encode the item vector using a preset sparse coding network to obtain the sparse vector corresponding to the selected target.
[0056] Here, the item vector refers to the vector obtained by vectorizing the selection targets in the historical selection data of the target object. In the scheme of this application, it is necessary to first determine the item vector corresponding to each selection target, and then construct the target object's corresponding vector by aggregating the item vectors. The pre-defined sparse coding network is a neural network used to implement the sparse coding process. The pre-defined sparse coding network is specifically constructed using an unsupervised training method, and the item vectors in the historical data can be directly used as the network's input and output to realize the training process of the pre-defined sparse coding network. The original input of the pre-defined sparse coding network is a densely encoded vector. After passing through the network, a sparse vector is obtained. If the sparse vector can reconstruct the input dense vector at the output, it means that the sparse vector contains most of the information of the original vector, and therefore can be used to represent the original vector. The principle of the sparse coding network is similar to that of the stacked encoder.
[0057] Specifically, the item vectors corresponding to the selection targets in historical selection data can be used as the base vectors for the sparse coding process. Then, a pre-constructed sparse coding network is used to sparsely encode the item vectors to obtain the sparse vectors corresponding to the selection targets. The acquisition of the item vectors corresponding to the selection targets can be based on the item features of the selection targets. When constructing the item vectors, the item features of the selection targets in different dimensions can be encoded, and the item vectors corresponding to the current selection targets can be obtained based on the results of these encodings. The item vectors are determined by combining different types of item features, such as text features, intrinsic features, and posterior features. This facilitates the fusion of multiple different types of item features to obtain accurate item vector representations. The cross-influence between different types of item features can be considered to accurately represent the attributes of the items, obtaining a more comprehensive vector representation result for each item. In one embodiment, after obtaining the sparse vectors, the pre-defined sparse coding network can be validated. Specifically, the obtained sparse vectors can be reconstructed, and the effect of the sparse coding is determined based on the difference between the reconstructed vectors and the item vectors. In this embodiment, the item vectors related to the target object are sparsely encoded by a preset sparse coding network, thereby effectively decoupling the item vectors.
[0058] In one embodiment, such as Figure 4 As shown, step 302 specifically includes:
[0059] Step 401: Obtain the item characteristics corresponding to the selected target in the historical selection data.
[0060] Among them, item features refer to the unique characteristics or attributes possessed by the selected target. Specifically, these include text features, inherent features, and posterior features.
[0061] Step 403: Group the item features corresponding to the selected target according to the feature type corresponding to the item features.
[0062] In this context, each item feature corresponding to the selected target can be grouped into a feature type. Therefore, based on the feature type corresponding to the item feature, the item features corresponding to the selected target can be grouped, for example, the item features can be divided into text feature group, intrinsic feature group, and posterior feature group, etc.
[0063] Step 405: Construct grouping vectors based on the vector encoding of the features of items within the group.
[0064] Vector coding refers to representing item features in an coded form, which effectively digitizes item features. Group coding, on the other hand, involves aggregating feature data within different feature groups into a unified vector. In a specific implementation, group vectors can be obtained by averaging the vector codes within each group.
[0065] Step 407: Obtain the item vector corresponding to the selected target based on the grouping vector of each group.
[0066] Specifically, the process of obtaining the item vector corresponding to the selected target can include first extracting different types of item features from the selected target, and then constructing item vectors based on these features. In this process, item features can be divided into groups based on their type, and then the average values of the encoded vectors of each group in different types are concatenated to construct the group vectors corresponding to the feature groups. For the item vector construction process, the concatenated group vectors can be subjected to dimensionality reduction and fitting to obtain the item vector of the selected target. Here, concatenating the average values of the encoded vectors of each group in different types specifically refers to mapping the grouped item features to corresponding vector codes; the vector codes of item features within the same group are averaged to determine the feature vector of the corresponding group. Finally, the feature vectors of different groups are concatenated to obtain the item vector corresponding to the item. In this embodiment, by selecting different types of item features from the target to construct the item vector, the accuracy of the item vector construction can be effectively guaranteed, thereby effectively identifying the vector corresponding to the target object.
[0067] In one embodiment, prior to step 304, a training process for a pre-defined sparse coding network is also included:
[0068] The first step in the training process is to obtain the model training vectors.
[0069] The model training vectors are the vector data used to train the pre-defined sparse coding network. Specifically, the model training vectors can be item vectors from historical data. The training process of the pre-defined sparse coding network is unsupervised training. Because the pre-defined sparse coding network uses an unsupervised training method, the samples are relatively easy to construct; the item vectors are directly used as the network's input and output. Therefore, the training sample format is (item vector, item vector). The pre-defined sparse coding network achieves sparse coding in the intermediate layers by reconstructing the input at the output. The significance of reconstruction is to ensure that the sparse vector can contain as much information as possible from the original vector.
[0070] Then, the model training vectors are input into the initial sparse coding network in batches to obtain the cross-entropy error and mean square error corresponding to the model training vectors.
[0071] Cross-entropy error and mean squared error are commonly used loss functions in neural networks. This application combines cross-entropy error and mean squared error to adjust the objective function in a pre-defined sparse coding network. Cross-entropy error characterizes the distance between two probability distributions. In this application, a hyperparameter vector is pre-defined to control sparsity. During model training, the mean value of the activated model training vectors after batching is fitted to this hyperparameter vector using cross-entropy error, thus making the activated model training vectors sufficiently sparse. Mean squared error refers to the expected value of the squared difference between the true value and the predicted value (estimated value). In this application, the mean squared error is determined by comparing the sparse vector after the objective function processing of the sparse coding network with the original object vector.
[0072] Once the cross-entropy error and mean square error are obtained, the total error can be determined based on these two factors.
[0073] When the total error is not less than the preset error threshold, the preset objective function is adjusted according to the cross-entropy error and the mean square error to update the initial sparse coding network. Then, the model training vectors are retrieved and input into the initial sparse coding network in batches to start a new round of unsupervised training.
[0074] When the total error is less than the preset error threshold, the current initial sparse coding network is used as the preset sparse coding network, and the training process of the preset sparse coding network ends.
[0075] The preset objective function refers to the function used to obtain the target result of the sparse coding network. After processing the input model training vector through the objective function, the final sparse coding result can be obtained. In a specific embodiment, the preset objective function can be the softmax function, i.e., the normalized exponential function. The softmax function can map the outputs of multiple neurons in the network to the (0,1) interval. The output of the softmax layer in the sparse coding network can be used as the sparse coding result of the item vector.
[0076] Specifically, in the scheme of this application, when training the sparse coding network, it is necessary to first obtain the model training vectors and the initial sparse coding network. Unsupervised training can be performed on the initial sparse coding network based on the model training vectors to obtain a preset sparse coding network suitable for sparse coding. During model training, the model training vectors are first input into the initial sparse coding network in batches, for example, a batch of 128 model training vectors at a time. Then, these batches of model training vectors are processed based on the initial sparse coding network to obtain the corresponding cross-entropy error and mean squared error, thus determining the loss. When the total error is not less than a preset error threshold, the preset objective function in the initial sparse coding network needs to be adjusted to update the initial sparse coding network, and training begins again with re-inputting model training vectors. When the obtained total error is less than the preset error threshold, it indicates that the final output sparse coding error is small and meets the requirements of the sparse coding process. In this case, the current initial sparse coding network can be used as the preset sparse coding network to complete the training of the initial sparse coding network. In this embodiment, by constructing model training vectors to train the initial sparse coding network to obtain the final preset sparse coding network, the availability of the preset sparse coding network can be effectively guaranteed.
[0077] In one embodiment, such as Figure 5 As shown, obtaining the cross-entropy error and mean squared error corresponding to the model training vectors includes:
[0078] Step 502: Activate the model training vectors of the current batch using an activation function to obtain the mean vector corresponding to the activated model training vectors of the current batch.
[0079] Step 504: Compare the mean vector with the preset hyperparameter vector to obtain the cross-entropy error.
[0080] Step 506: Obtain the training encoding vector by using the preset objective function and the model training vector of the current batch after activation.
[0081] Step 508: Obtain the mean squared error based on the training encoding vector and the model training vector of the current batch.
[0082] The activation function is the Sigmoid function, a common sigmoid function in biology, also known as an sigmoid growth curve. In information science, due to its monotonically increasing and inverse monotonically increasing properties, the Sigmoid function is often used as the activation function of neural networks, mapping variables to the range of 0 and 1. The hyperparameter vector is a hyperparameter used to control sparsity; each dimension has the same value, and a value of 0.1 indicates that approximately 10% of the nodes will be activated.
[0083] Specifically, after inputting a batch of model training vectors into the initial sparse coding network, the fully connected layer first activates this batch of model training vectors using an activation function and calculates the corresponding mean vector. Then, the cross-entropy error is obtained by comparing the mean vector with the preset hyperparameter vector. Next, the activated batch of model training vectors is processed by a preset objective function to output a training encoding vector, which is the output sparse code. At this point, the training encoding vector can be compared with the current batch of model training vectors to obtain the mean squared error. In specific application scenarios, the preset hyperparameter vector can be a vector with equal values in all dimensions, all taking a value of 0.1, thus controlling the sparsity of the preset sparse coding network after training to be 0.1. When training the initial sparse coding network, in each round of model training, the model training vectors are first input into the initial sparse coding network to perform sparse coding and obtain the error generated during the encoding process of the initial sparse coding network in the current round. In the error calculation process, the model training vectors of the current batch need to be activated using an activation function. By comparing the activated result with the preset hyperparameter vector, a cross-entropy error can be obtained. If the activated result is a vector that perfectly matches the sparsity, then approximately 10% of the nodes are activated and assigned a value of 1, while the other nodes are assigned a value of 0. Furthermore, since the model training vectors in each batch are sufficiently random, each dimension of the activated mean vector is close to 0.1. In this case, the cross-entropy error is small. The cross-entropy error forces the activated mean vector to fit the hyperparameter vector, ensuring that the activated result closely matches the set sparsity and guarantees sufficient sparsity. Simultaneously, after obtaining the cross-entropy error, the mean squared error (MSE) also needs to be obtained. The MSE is determined by comparing the model's input and output. By encoding the activated model training vector using the preset objective function in the initial sparse coding network, the sparsely encoded training vector can be obtained. At this point, the training vector can be compared with the input model training vector to obtain the MSE. Then, in the current round of model training, the loss function of the initial sparse coding network is adjusted based on the obtained cross-entropy error and MSE, and the next round of training begins. In this embodiment, the cross-entropy error can be effectively determined by comparing the mean vector with the preset hyperparameter vector, and the MSE can be effectively determined by comparing the model's input and output vectors, thereby accurately realizing model adjustment during the training process of the preset sparse coding network.
[0084] In one embodiment, such as Figure 6 As shown, step 506 includes:
[0085] Step 601: Squaring the training vectors of the current batch of activated models to obtain a squared vector.
[0086] Step 603: Process the squared vector using a preset objective function to obtain the training encoding vector.
[0087] The squaring process involves squaring the parameters in the vector. After processing the current batch of model training vectors using an activation function, the variables in each dimension of the training vectors are mapped to the range of 0 and 1. This squaring further suppresses small values and boosts large values, thus ensuring the effectiveness of sparse coding.
[0088] Specifically, after processing the model training vectors using an activation function, to ensure the encoding effect during sparse encoding, the activated training vectors of the current batch can be squared to obtain a squared vector. This squared vector is then processed using a preset objective function to output the final training encoding vector. In a specific embodiment, such as... Figure 7 As shown, in a complete model training process, a batch of model training vectors with a size of 128 is first input into the fully connected layer (Dense) of the initial sparse coding network, and then activated by the sigmoid function. The mean vector of the activated model training vector is then calculated. The mean vector is then compared with the preset hyperparameter vector to obtain the cross-entropy error, i.e., loss2. At the same time, the activated model training vector needs to be squared (pow(2)) to obtain a square vector. Then, the square vector is processed by the preset objective function softmax to output the sparse code, i.e., the training code vector. By comparing the output training code vector with the input model training vector, the effect of sparse coding is determined, and the mean square error, i.e., loss1, is obtained. By combining loss1 and loss2, the final total error loss = loss1 + α*loss2 is obtained, thereby adjusting the initial sparse coding network. The initial sparse coding network is trained iteratively. When the final verification is passed, it can be judged that the initial sparse coding network training is completed, and a preset sparse coding network that can be used for sparse coding is obtained. In this embodiment, the squaring process can effectively guarantee the coding effect during the sparse coding process.
[0089] In one embodiment, such as Figure 8 As shown, step 205 includes:
[0090] Step 801: Obtain the mean of the sparse vectors corresponding to all selected targets of the target object in each dimension.
[0091] Step 803: Construct the vector corresponding to the target object based on the mean of each dimension.
[0092] Specifically, a sparse vector contains parameter values in different dimensions, and this application can construct the final vector based on the specific parameter values in each dimension of the sparse vectors corresponding to all selected targets of the target object. In this application, a mean aggregation method can be used to construct the vector corresponding to the target object. First, the selected targets corresponding to the target object are vectorized using sparse encoding to obtain sparse codes, thereby decoupling the item vectors corresponding to the selected targets in different dimensions. Then, by averaging the sparse vectors of all selected targets corresponding to the target object along each dimension, the generated new vector is the vector to be obtained. In one embodiment, for a target object, assuming 10 selected targets are selected to determine the vector corresponding to the target object. At this time, it is first necessary to obtain the item vectors corresponding to these 10 selected targets. Then, the item vectors are sparsely encoded using a preset sparse encoding network. Having obtained 10 sparse vectors corresponding to the selected targets, when calculating the vector corresponding to the final target object, it is necessary to obtain the mean of these 10 sparse vectors in each dimension. Based on the mean of each dimension, the value of the target object's vector in each dimension is determined. Concatenating the values of the target object's vector in each dimension yields the vector corresponding to the final target object. Therefore, the vector corresponding to the target object has the i-th dimension x... i The value of is calculated according to the following formula, where n is the number of items, and y is the value of . ji Let be the value of the i-th dimension of the j-th item.
[0093]
[0094] In this embodiment, mean aggregation can effectively aggregate all sparse vectors corresponding to the target object to obtain the final item vector, thus ensuring the validity of the item vector.
[0095] In one embodiment, after step 205, the method further includes: obtaining the item vector corresponding to the content to be recommended; and recommending content to the target object based on the vector corresponding to the target object and the item vector corresponding to the content to be recommended.
[0096] Specifically, after determining the vector corresponding to the target object, this vector can be used to recommend content related to the target object. This process can be achieved by comparing the vector corresponding to the target object with the item vectors corresponding to each piece of content to be recommended. Since both the vector corresponding to the target object and the item vectors can be represented as a point in the vector space, the problem of recommending content related to the target object based on the vector corresponding to the target object can be transformed into calculating the distance between the vector corresponding to the target object and each item vector in the vector space. The shorter the distance, the greater the relevance between the vector corresponding to the target object and the item vectors. Therefore, in one embodiment, when making recommendations, the distance between the vector corresponding to the target object and the item vectors corresponding to the content to be recommended can be calculated first. Then, the content to be recommended corresponding to the item vectors whose distance to the vector corresponding to the target object is less than a preset distance threshold can be recommended to the target object, thereby achieving content recommendation related to the target object. In another embodiment, after obtaining the vector distances between the item vectors corresponding to different pieces of content to be recommended and the vector corresponding to the target object, these vector distances can be ranked, and then the content to be recommended within the preset ranking can be recommended to the target object. In the embodiments of this application, by comparing the distance relationship between the vector corresponding to the target object and the item vector, it is possible to effectively recommend content related to the target object and ensure the accuracy of the content recommendation.
[0097] This application also provides an application scenario in which the above-described vector construction method for a target object is applied. Specifically, the application of the vector construction method for the target object in this scenario is as follows:
[0098] In this embodiment, the target object can specifically be a user, and the vector for the target object is the user vector of the user object. Specifically, this scenario can be a video recommendation scenario. When a user browses a video website and needs video content recommendations, the user can click on a dedicated recommendation form within the website to obtain recommended video content corresponding to the user. The dedicated recommendation form can be constructed based on the user's corresponding user vector. By collecting video content clicked by the user from historical data, and then using a preset sparse coding network to sparsely encode the item vectors corresponding to these video content, sparse vectors corresponding to the item vectors are obtained. Then, by aggregating all the sparse vectors, the final user vector is obtained. The user vector is then compared with the item vectors corresponding to all video content to obtain the distance between the user vector and the item vectors corresponding to all video content, and a corresponding distance ranking is established. Then, the recommended content in the dedicated recommendation form is determined based on the video content ranked highest in the distance ranking. The complete process of constructing the complete user vector can be found in [reference needed]. Figure 9As shown, the first step is to obtain item vectors. These item vectors are primarily used as training vectors to train the constructed sparse coding network. Specifically, when constructing item vectors, the features of the selected target across different dimensions are encoded. The item vector corresponding to the currently selected target is then obtained based on the results of these encodings. Item vectors are determined by combining different types of item features. For example, textual features, intrinsic features, and posterior features can be combined. This facilitates the fusion of multiple different types of item features to obtain an accurate item vector representation. Furthermore, the cross-influence between different types of item features can be considered to accurately characterize item attributes, resulting in a more comprehensive vector representation for each item. The training process of the preset sparse coding network is an unsupervised training process, which includes: first, generating model training data based on the obtained item vectors, and then inputting the model training vectors into the initial sparse coding network in batches; obtaining the cross-entropy error and mean square error corresponding to the model training vectors, and determining the total error based on the cross-entropy error and mean square error; when the total error is not less than the preset error threshold, adjusting the objective function of the sparse coding network based on the cross-entropy error and mean square error to update the initial sparse coding network, and then returning to the steps of obtaining model training vectors and inputting them into the initial sparse coding network in batches to start the next round of training; when the total error is less than the preset error threshold, the current initial sparse coding network can be used as the preset sparse coding network to complete the training of the initial sparse coding network. The process of obtaining the cross-entropy error and mean squared error corresponding to the model training vectors includes: activating the current batch of model training vectors using an activation function to obtain the mean vector of the activated current batch of model training vectors; comparing the mean vector with a preset hyperparameter vector to obtain the cross-entropy error; squaring the activated current batch of model training vectors to obtain the squared vector; processing the squared vector with a preset objective function to obtain the training encoding vector; and obtaining the mean squared error based on the training encoding vector and the current batch of model training vectors. By calculating these two errors separately, the objective function in the initial sparse coding network can be effectively adjusted, thereby optimizing the initial sparse coding network. After the sparse coding network is trained, it can be used to calculate user vectors. This process first requires collecting the items clicked by the user, specifically the videos clicked in this case. Then, the item vectors corresponding to these videos are sparsely encoded to obtain sparse vectors. These sparse vectors are then aggregated using a mean aggregation method, i.e., by obtaining the mean of all sparse vectors corresponding to the selected targets of the target object in each dimension, and constructing the user vector based on the mean of each dimension.
[0099] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0100] Based on the same inventive concept, this application also provides a vector construction apparatus for implementing the vector construction method for a target object as described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more embodiments of the vector construction apparatus for a target object provided below can be found in the limitations of the vector construction method for a target object described above, and will not be repeated here.
[0101] In one embodiment, such as Figure 10 As shown, a vector construction apparatus for a target object is provided, comprising:
[0102] The data acquisition module 1001 is used to acquire historical selection data of the target object.
[0103] The vector mapping module 1003 is used to map the selection target in the historical selection data into a sparse vector through sparse coding.
[0104] Vector construction module 1005 is used to construct the vector corresponding to the target object based on the sparse vector corresponding to the selected target.
[0105] In one embodiment, the vector mapping module 1003 is specifically used to: obtain historical selection data of the target object; map the selection target in the historical selection data into a sparse vector through sparse coding; and construct the vector corresponding to the target object based on the sparse vector corresponding to the selection target.
[0106] In one embodiment, the vector mapping module 1003 is further configured to: obtain the item vector corresponding to the selection target in the historical selection data; and perform sparse encoding on the item vector through a preset sparse encoding network to obtain the sparse vector corresponding to the selection target.
[0107] In one embodiment, the vector mapping module 1003 is further configured to: obtain the item features corresponding to the selection target in the historical selection data; group the item features corresponding to the selection target according to the feature type corresponding to the item features; construct a grouping vector according to the vector encoding of the item features in the group; and obtain the item vector corresponding to the selection target based on the grouping vector of each group.
[0108] In one embodiment, the system further includes an encoding network training module, configured to: acquire model training vectors; input the model training vectors into an initial sparse encoding network in batches, and acquire the cross-entropy error and mean square error corresponding to the model training vectors; determine the total error based on the cross-entropy error and mean square error; when the total error is not less than a preset error threshold, adjust the objective function of the initial sparse encoding network based on the cross-entropy error and mean square error to update the initial sparse encoding network, and return to the steps of acquiring model training vectors and inputting model training vectors into the initial sparse encoding network in batches; when the total error is less than the preset error threshold, use the current initial sparse encoding network as the preset sparse encoding network.
[0109] In one embodiment, the encoding network training module is further configured to: activate the model training vectors of the current batch using an activation function to obtain the mean vector corresponding to the activated model training vectors of the current batch; compare the mean vector with a preset hyperparameter vector to obtain the cross-entropy error; obtain the training encoding vector using a preset objective function and the activated model training vectors of the current batch; and obtain the mean squared error based on the training encoding vector and the model training vectors of the current batch.
[0110] In one embodiment, the encoding network training module is further configured to: squaring the model training vectors of the current batch after activation to obtain a squared vector; and processing the squared vector through a preset objective function to obtain a training encoding vector.
[0111] In one embodiment, the vector construction module 1005 is specifically used to: obtain the mean of all sparse vectors corresponding to the selected targets of the target object in each dimension; and construct the vector corresponding to the target object based on the mean of each dimension.
[0112] In one embodiment, a content recommendation module is also included, which is used to: obtain the item vector corresponding to the content to be recommended; and recommend content to the target object based on the vector corresponding to the target object and the item vector corresponding to the content to be recommended.
[0113] Each module in the aforementioned vector construction device for the target object can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0114] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11 As shown. The computer device includes a processor, memory, and network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores data related to the vector construction process. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a vector construction method for a target object. Those skilled in the art will understand that... Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0115] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0116] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0117] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.
[0118] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0119] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0120] It is understood that in the specific implementation of this application, data related to user information, user behavior, and user logs are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0121] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0122] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for constructing a vector for a target object, characterized in that, The method includes: Obtain historical selection data for the target object; Obtain the item vector corresponding to the selection target in the historical selection data. The item vector is obtained by encoding the item features of the selection target in different dimensions. The item vector is sparsely encoded by a preset sparse coding network to obtain the sparse vector corresponding to the selected target. The input of the preset sparse coding network is a dense form of the item vector, and the sparse vector corresponding to the selected target can be used to reconstruct the dense form of the item vector at the output. Obtain the mean of the sparse vectors corresponding to all selected targets of the target object in each dimension; construct the vector corresponding to the target object based on the mean of each dimension; Get the item vectors corresponding to the content to be recommended; Content recommendations are made to the target object based on the vector corresponding to the target object and the item vector corresponding to the content to be recommended.
2. The method according to claim 1, characterized in that, The step of obtaining the item vector corresponding to the selection target in the historical selection data includes: Obtain the item characteristics corresponding to the selected target from the historical selection data; Based on the feature type corresponding to the item features, group the item features corresponding to the selected target; Construct grouping vectors based on the vector encoding of the features of items within the group; The item vector corresponding to the selected target is obtained based on the grouping vector of each group.
3. The method according to claim 1, characterized in that, Before obtaining the sparse vector corresponding to the selected target by sparse encoding the item vector through a preset sparse coding network, the method further includes: Obtain the model training vectors; The model training vectors are input into the initial sparse coding network in batches to obtain the cross-entropy error and mean square error corresponding to the model training vectors. The total error is determined based on the cross-entropy error and the mean square error. When the total error is not less than the preset error threshold, the objective function of the initial sparse coding network is adjusted according to the cross-entropy error and the mean square error to update the initial sparse coding network, and the steps of obtaining the model training vector and inputting the model training vector into the initial sparse coding network in batches are returned. When the total error is less than the preset error threshold, the current initial sparse coding network is used as the preset sparse coding network.
4. The method according to claim 3, characterized in that, The step of obtaining the cross-entropy error and mean squared error corresponding to the model training vector includes: The model training vectors of the current batch are activated by an activation function, and the mean vector corresponding to the activated model training vectors of the current batch is obtained. The mean vector is compared with the preset hyperparameter vector to obtain the cross-entropy error; The training encoding vector is obtained by using a preset objective function and the model training vector of the current batch after activation; The mean squared error is obtained based on the training encoding vector and the model training vector of the current batch.
5. The method according to claim 4, characterized in that, The process of obtaining the training encoding vector through a preset objective function and the activated training vector of the current batch includes: Squaring the training vectors of the current batch of activated models yields a squared vector. The squared vector is processed by a preset objective function to obtain the training encoded vector.
6. A vector construction apparatus for a target object, characterized in that, The device includes: The data acquisition module is used to acquire historical selection data of the target object; The vector mapping module is used to obtain the item vector corresponding to the selection target in the historical selection data. The item vector is obtained by encoding the item features of the selection target in different dimensions. The item vector is sparsely encoded by a preset sparse coding network to obtain the sparse vector corresponding to the selection target. The input of the preset sparse coding network is a dense form of item vector. The sparse vector corresponding to the selection target can be used to reconstruct the dense form of item vector at the output. The vector construction module is used to obtain the mean of the sparse vectors corresponding to all selected targets of the target object in each dimension; and to construct the vector corresponding to the target object based on the mean of each dimension. The content recommendation module is used to obtain the item vectors corresponding to the content to be recommended; and to recommend content to the target object based on the vectors corresponding to the target object and the item vectors corresponding to the content to be recommended.
7. The apparatus according to claim 6, characterized in that, The vector mapping module is specifically used for: obtaining the item features corresponding to the selection target in the historical selection data; grouping the item features corresponding to the selection target according to the feature type corresponding to the item features; constructing a grouping vector according to the vector encoding of the item features within the group; and obtaining the item vector corresponding to the selection target based on the grouping vector of each group.
8. The apparatus according to claim 6, characterized in that, It also includes an encoding network training module, used for: obtaining model training vectors; inputting the model training vectors into an initial sparse encoding network in batches, obtaining the cross-entropy error and mean square error corresponding to the model training vectors; determining the total error based on the cross-entropy error and the mean square error; when the total error is not less than a preset error threshold, adjusting the objective function of the initial sparse encoding network based on the cross-entropy error and the mean square error to update the initial sparse encoding network, returning to the steps of obtaining model training vectors and inputting the model training vectors into the initial sparse encoding network in batches; when the total error is less than the preset error threshold, using the current initial sparse encoding network as the preset sparse encoding network.
9. The apparatus according to claim 8, characterized in that, The encoding network training module is further configured to: activate the model training vectors of the current batch using an activation function to obtain the mean vector corresponding to the activated model training vectors of the current batch; compare the mean vector with a preset hyperparameter vector to obtain the cross-entropy error; obtain the training encoding vector using a preset objective function and the activated model training vectors of the current batch; and obtain the mean squared error based on the training encoding vector and the model training vectors of the current batch.
10. The apparatus according to claim 9, characterized in that, The encoding network training module is further configured to: squaring the activated model training vectors of the current batch to obtain a squared vector; and processing the squared vector using a preset objective function to obtain a training encoding vector.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.