Data processing method and device, equipment and medium
By using a pre-trained language model in the sequence recommendation model combined with a dual-task strategy of masked language modeling and item comparison tasks, the problem of the effectiveness of initialization of item embedded information in the existing technology is solved, and the recommendation effect is improved.
Patent Information
- Application Number
- CN202410350475.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-25
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-03-25
AI Technical Summary
In the initialization process of item embedded information, existing sequence recommendation models are limited by random initialization or text representation vectorization, which limits the effectiveness of item embedded information and affects the recommendation effect.
A dual-task strategy using a pre-trained language model combined with masked language modeling and item comparison tasks is used to train and adjust the pre-trained language model, generate item embedding representations for initialization, and make full use of prior knowledge to extract the sequence of historical item sequences. feature.
The effectiveness of the item embedding representation is improved, and the recommendation effect of the sequence recommendation model is improved. The item embedding table is initialized through the adjusted pre-trained language model, which enhances the performance of the recommendation model.
Smart Images

Figure CN118861671A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a data processing method, device, equipment and medium. Background Art
[0002] Sequential recommendation is an important task in the recommendation system. It models the historical item interaction sequences of each object (such as the sequence of purchased items), learns the interest changes of each object, and then predicts the next interactive item of each object. In the current sequence recommendation modeling scenario, the historical item interaction sequence is used to train the sequence recommendation model. The trained sequence recommendation model can extract the feature expression of the object's interest. These feature expressions can be combined with the item embedding information corresponding to each item to recommend the next interactive item of the object. It can be seen that the quality of the item embedding information will directly affect the recommendation effect of the trained sequence recommendation model. The current item embedding information is usually initialized randomly or by using a network model to initialize the vector obtained by vectorizing the text representation of the item. Due to the huge representation difference between the text representation of the item and the historical item interaction sequence, the effectiveness of the item embedding information is affected. Summary of the invention
[0003] The embodiments of the present application provide a data processing method, apparatus, device, and medium, which can fully utilize the prior knowledge in the pre-trained language model to enhance the effectiveness of object embedding representation.
[0004] On the one hand, an embodiment of the present application provides a data processing method, including:
[0005] Obtain a first text representation corresponding to each item in the item set, and obtain a second text representation corresponding to the historical item sequence of each object in the object set based on the first text representation;
[0006] Generate a first training sample according to the second text representation, perform text prediction on the first training sample according to the pre-trained language model, and obtain a prediction probability corresponding to a hidden position in the first training sample; the first training sample includes a positive sample and a negative sample;
[0007] According to the pre-trained language model, an object comparison is performed between the first training sample and a first positive sample corresponding to the first training sample to obtain a first sample similarity;
[0008] Training the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model;
[0009] Generate a second training sample according to the second text representation, and perform an item comparison on the second training sample and the second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity; the second training sample does not contain the positive sample;
[0010] The trained pre-trained language model is adjusted according to the second sample similarity to obtain an adjusted pre-trained language model; the adjusted pre-trained language model is used to initialize the embedding representation of the object.
[0011] An embodiment of the present application provides a data processing device, including:
[0012] A text acquisition module, used to acquire a first text representation corresponding to each item in the item set, and acquire a second text representation corresponding to the historical item sequence of each object in the object set according to the first text representation;
[0013] A text prediction module is used to generate a first training sample according to the second text representation, perform text prediction on the first training sample according to the pre-trained language model, and obtain a prediction probability corresponding to a hidden position in the first training sample; the first training sample includes a positive sample and a negative sample;
[0014] A first item comparison module, configured to perform an item comparison on the first training sample and a first positive sample corresponding to the first training sample according to a pre-trained language model to obtain a first sample similarity;
[0015] A model pre-training module, used to train the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model;
[0016] A second item comparison module is used to generate a second training sample according to the second text representation, and to compare the second training sample with a second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity; the second training sample does not contain the positive sample;
[0017] The model adjustment module is used to adjust the trained pre-trained language model according to the second sample similarity to obtain an adjusted pre-trained language model; the adjusted pre-trained language model is used to initialize the embedded representation of the object.
[0018] The text acquisition module acquires a first text representation corresponding to each item in the item set, and acquires a second text representation corresponding to the historical item sequence of each object in the object set according to the first text representation, so as to perform the following steps:
[0019] Obtaining an item type, an item identifier, and an item name corresponding to each item in the item set, and combining the item type, item identifier, and item name corresponding to the same item to obtain a first text representation corresponding to each item;
[0020] Obtaining a historical item sequence corresponding to each object in the object set, and sorting the items in the historical item sequence in descending order according to the interaction time corresponding to the items in the historical item sequence, to obtain a sorted historical item sequence;
[0021] The first text representations corresponding to the items included in the sorted historical item sequence are concatenated to obtain the second text representations corresponding to the historical item sequence of each object.
[0022] The text prediction module generates a first training sample according to the second text representation, and is used to perform the following steps:
[0023] Determine a hidden position in the second text representation according to the text selection ratio, and determine the text in the hidden position as a candidate text representation;
[0024] The candidate text representation in the second text representation is subjected to hiding processing to obtain an initial sample, and a marker text is added to the initial sample to obtain a first training sample.
[0025] The text prediction module performs hidden processing on the candidate text representation in the second text representation to obtain an initial sample for performing the following steps:
[0026] Using the first hiding probability and the second hiding probability, hiding the candidate text representation in the second text representation to obtain an initial sample;
[0027] The first hiding probability refers to the probability of replacing the candidate text representation in the second text representation with the mask, and the second hiding probability refers to the probability of replacing the candidate text representation in the second text representation with the random text representation.
[0028] The text prediction module performs text prediction on the first training sample according to the pre-trained language model to obtain the prediction probability corresponding to the hidden position in the first training sample, which is used to perform the following steps:
[0029] Inputting the first training sample into the pre-trained language model, encoding the first training sample through the pre-trained language model, and obtaining a first sample embedding representation corresponding to the first training sample;
[0030] Perform text prediction on the hidden position in the first training sample according to the first sample embedding representation to obtain a prediction probability corresponding to the hidden position in the first training sample.
[0031] The first item comparison module compares the first training sample with the first positive sample corresponding to the first training sample according to the pre-trained language model to obtain a first sample similarity, which is used to perform the following steps:
[0032] The first text representation of the subsequent interaction item corresponding to the first training sample is determined as the first positive sample; the first training sample and the first positive sample are historical interaction items of the same object;
[0033] Inputting the first positive sample into the pre-trained language model, encoding the first positive sample through the encoder in the pre-trained language model, and obtaining a second sample embedding representation corresponding to the first positive sample;
[0034] A first object embedding representation corresponding to the object associated with the first positive sample is obtained, and a first sample similarity is obtained according to the first object embedding representation, the second sample embedding representation, and the first sample embedding representation corresponding to the first training sample.
[0035] Wherein, the number of the first training samples is M, and M is a positive integer;
[0036] The first object comparison module obtains a first sample similarity according to the first object embedding representation, the second sample embedding representation, and the first sample embedding representation corresponding to the first training sample, and is used to perform the following steps:
[0037] Obtaining a first feature similarity between the first object embedding representation and the second sample embedding representation, performing an exponential operation on the first feature similarity, and obtaining a first similarity candidate value;
[0038] Obtaining a second feature similarity between the first object embedding representation and the first sample embedding representation corresponding to each first training sample, performing an exponential operation on the second feature similarity, and obtaining a second candidate similarity value associated with each first training sample;
[0039] The second candidate similarity values associated with each first training sample are accumulated to obtain a cumulative similarity value, and the first sample similarity is determined according to a ratio between the first similarity candidate value and the cumulative similarity value.
[0040] Wherein, the number of hidden positions in the first training sample is N, and N is a positive integer;
[0041] The model pre-training module trains the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model for performing the following steps:
[0042] Perform logarithmic operation on the predicted probabilities corresponding to the N hidden positions to obtain the logarithmic value of the probability of each hidden position, and accumulate the logarithmic values of the probability of each hidden position to obtain and determine the masked language modeling loss;
[0043] Determine a model training loss corresponding to the pre-trained language model according to the masked language modeling loss and the first sample similarity;
[0044] According to the model training loss, the network parameters of the pre-trained language model are iteratively trained until the model training loss meets the training end condition, then the training is stopped to obtain the trained pre-trained language model.
[0045] The second item comparison module generates a second training sample according to the second text representation, and performs an item comparison on the second training sample and the second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity, which is used to perform the following steps:
[0046] Adding a marker text to the second text representation to obtain a second training sample, and determining a second positive sample corresponding to the second training sample;
[0047] Obtain a third sample embedding representation corresponding to the second training sample through the pre-trained language model, and obtain a fourth sample embedding representation corresponding to the second positive sample through the pre-trained language model;
[0048] A second object embedding representation corresponding to the object associated with the second positive sample is obtained, and a second sample similarity is obtained according to the second object embedding representation, the third sample embedding representation, and the fourth sample embedding representation.
[0049] The data processing device may further include:
[0050] An item input text acquisition module, used to add a marker text to the first text representation corresponding to each item in the item set, to obtain the item input text corresponding to each item in the item set;
[0051] An item embedding representation acquisition module is used to input the item input text corresponding to item a in the item set into the adjusted pre-trained language model, and obtain the item embedding representation corresponding to item a through the adjusted pre-trained language model;
[0052] The item embedding table generation module is used to obtain the item embedding representation corresponding to each item in the item set, and add the item embedding representation corresponding to each item to the item embedding table.
[0053] The data processing device may further include:
[0054] A training sample generating module, used for generating a third training sample of the sequence recommendation model according to the item embedding representation in the item embedding table and the historical item sequence corresponding to each object in the object set;
[0055] A recommendation model training module, used to train the sequence recommendation model according to the third training sample to obtain a trained sequence recommendation model;
[0056] Among them, the training of the sequence recommendation model includes the first stage and the second stage. The first stage is used to train the sequence modeling task, and the training of the item embedding representation is suspended; the second stage is used to train the item embedding representation, and the training of the sequence modeling task is suspended; the trained sequence recommendation model is used for item recommendation.
[0057] On one hand, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory is connected to the processor, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method provided in the above aspect of the embodiment of the present application.
[0058] On one hand, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. The computer program is suitable for being loaded and executed by a processor, so that a computer device with a processor executes the method provided in the above aspect of the embodiment of the present application.
[0059] According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the method provided in the above aspect.
[0060] In an embodiment of the present application, a first text representation corresponding to each item in an item set is obtained, and the first text representations corresponding to the items contained in the historical item sequence of each object are spliced to obtain a second text representation corresponding to the historical item sequence; a first training sample for training a pre-trained language model and a second training sample for adjusting the trained pre-trained language model are constructed according to the second text representation. Based on the first training sample, the pre-trained language model is trained using a dual-task strategy of masked language modeling (text prediction) and item comparison to obtain a trained pre-trained language model. Based on the second training sample, the pre-trained language model is adjusted using an item comparison strategy to obtain an adjusted pre-trained language model. The above-mentioned adjusted pre-trained language model can provide an initialized item embedding representation for sequence recommendation, and can make full use of the prior knowledge of the pre-trained language model to extract sequence features in the historical item sequence, thereby enhancing the effectiveness of the item embedding representation. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0062] Figure 1 It is a structural diagram of a network architecture provided by an embodiment of the present application;
[0063] Figure 2 It is a flowchart of a data processing method provided in an embodiment of the present application;
[0064] Figure 3 is a schematic diagram of a text representation construction provided by an embodiment of the present application;
[0065] Figure 4 It is a training diagram of a pre-trained language model provided in an embodiment of the present application;
[0066] Figure 5 It is a flowchart of an item embedding initialization based on a pre-trained language model provided in an embodiment of the present application;
[0067] Figure 6 is a training diagram of a sequence recommendation task provided in an embodiment of the present application;
[0068] Figure 7 is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0069] Figure 8It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0070] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0071] For ease of understanding, the basic technical concepts involved in the embodiments of the present application are described below:
[0072] Natural Language Processing (NLP): Natural language processing is an important direction in the fields of computer science and artificial intelligence (AI). It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0073] Among them, the embodiments of the present application specifically relate to text processing under natural language processing. In the sequence recommendation scenario, a text representation of an item is constructed. By text encoding the text representation of the item, an item embedding representation corresponding to each item can be obtained. The item embedding representation can be used as the initialization embedding representation of the item in the sequence recommendation task, which can enhance the effectiveness of the item embedding representation.
[0074] See also Figure 1 , Figure 1 1 is a schematic diagram of a network architecture provided by an embodiment of the present application. The network architecture may include a server 10d and a terminal cluster. The terminal cluster may include one or more terminal devices. The number of terminal devices included in the terminal cluster is not limited. Figure 1 As shown, the terminal cluster may specifically include terminal device 10a, terminal device 10b, and terminal device 10c, etc.; all terminal devices in the terminal cluster (for example, including terminal device 10a, terminal device 10b, and terminal device 10c, etc.) may be connected to the server 10d through a network connection, so that each terminal device may exchange data with the server 10d through the network connection.
[0075] The terminal devices of the terminal cluster may include smart phones, tablet computers, laptop computers, PDAs, mobile internet devices (MID), wearable devices (such as smart watches, smart bracelets, etc.), smart voice interaction devices, smart home appliances (such as smart TVs, etc.), vehicle-mounted devices, aircraft and other electronic devices. This application does not limit the type of terminal devices. It is understandable that, for example, Figure 1 Each terminal device in the terminal cluster shown can be installed with a business application. When the business application runs in each terminal device, it can be respectively connected to the above Figure 1 The server 10d shown in the figure performs data interaction. The service application running in each terminal device may correspond to an independent client or an embedded sub-client integrated in a client, which is not limited in the present application.
[0076] Among them, the business application may specifically include but is not limited to: applications with item recommendation functions such as browsers, in-vehicle applications, smart home applications, shopping applications, and content interaction applications. Among them, if the terminal device included in the terminal cluster is an in-vehicle device, then the in-vehicle device can be an intelligent terminal in the smart transportation scenario, and the business application running in the in-vehicle device can be called an in-vehicle application.
[0077] Among them, server 10d can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms. This application does not limit the type of server.
[0078] Understandably, Figure 1One or more business applications can be installed in each of the terminal devices shown, and a sequence recommendation model can be integrated in each business application. The sequence recommendation model here may include but is not limited to: SASRec (Self-Attentive Sequential Recommendation), BERT4Rec (Sequential Recommendation with Bidirectional Encoder Representationsfrom Transformer, a sequence recommendation model based on Transformer bidirectional encoding representation), IDA-SR (Towards Universal Sequence Representation Learning for Recommender Systems, universal sequence representation learning in recommendation systems), etc. This application does not limit the network structure of the sequence recommendation model. For the sequence recommendation model involved in this application, the input of the sequence recommendation model may refer to the item interaction sequence feature, which may be composed of the item embedding representations corresponding to two or more items. Among them, the item interaction sequence can refer to the item sequence generated by the object on a certain platform; for example, the items purchased by object A on a certain platform are in the order of purchase time: item 1, item 2, item 3, item 4, then the item interaction sequence of object A can be expressed as [item 1, item 2, item 3, item 4]; item embedding representation refers to mapping items into a continuous, low-dimensional vector space so that computer devices can better understand and process these items.
[0079] In the embodiment of the present application, a pre-trained language model can be used for pre-training in training sets of multiple fields. If resources permit, the pre-trained language model can be further adjusted on the training set of a specific field. Then, the pre-trained language model that has been trained can be used to initialize the item embedding table of the sequence recommendation model to enhance the effectiveness of the item embedding representation, thereby improving the recommendation effect of the sequence recommendation model. Among them, the item embedding table may include item embedding representations corresponding to multiple items, and the item ID (Identity document) of each item can be used as the index information of the item in the item embedding table. For example, the item ID can be used to query the item embedding representation corresponding to the item contained in the item interaction sequence of the object from the item embedding table to form the item interaction sequence feature input into the sequence recommendation model.
[0080] The pre-trained language model involved in the embodiments of the present application may refer to a language model trained on large-scale text data, which can be used to learn rich language knowledge and grammatical rules. The goal of the pre-trained language model is to learn language representation on unlabeled text data so that it has good generalization ability and can be applied to various natural language processing tasks. The pre-trained language model generally includes two steps: ① Pretraining stage (Pretraining), in which the model can learn knowledge such as the grammatical structure, semantic information, and contextual association of the text. ② Fine-tuning stage (Fine-tuning), fine-tuning on specific downstream tasks (for example, text type, language understanding, etc.) to adapt to the needs of specific tasks and improve the performance of the model on the task. Among them, the pre-trained language model may include but is not limited to: BERT (Bidirectional Encoder Representations from Transformers, based on Transformer's bidirectional encoding representation), GPT (Generative Pretrained Transformer, generative pre-trained Transformer), RoBERTa (Robustly optimized BERT approach, optimized BERT pre-training method), Longformer (The Long-Document Transformer, based on long text Transformer), etc. This application does not limit the network structure of the pre-trained language model. The pre-trained language model in the embodiment of the present application belongs to a pre-trained model, which can also be called a language model, or can be called a large language model, which is not limited in this application.
[0081] See also Figure 2 , Figure 2 is a flow chart of a data processing method provided in an embodiment of the present application; it can be understood that the data processing method can be executed by a computer device, and the computer device can be a server (such as Figure 1 The server 10d shown in FIG. 10a may be a terminal device (eg, Figure 1 Any terminal device in the terminal cluster shown in the figure), which is not limited in this application. Figure 2 As shown, the data processing method may include the following steps S101 to S106:
[0082] Step S101, obtaining a first text representation corresponding to each item in an item set, and obtaining a second text representation corresponding to a historical item sequence of each object in an object set according to the first text representation.
[0083] In the embodiment of the present application, a business application with an integrated sequence recommendation function can be run in a computer device, and the items in the business application can be obtained, and the items in the business application can be added to the item collection. In addition, the registered objects in the business application can be obtained, and the registered objects in the business application can be added to the object collection, and then the interactive item sequence corresponding to each object in the object collection can be obtained according to the interaction records of each object in the object collection in the business platform. Among them, the above-mentioned interaction records can refer to the item purchase records, item sharing records, item collection records, etc. of each object in the business platform, and this application does not limit this; the items included in the interactive item sequence can be sorted according to the item interaction time (for example, purchase time, sharing time, collection time, etc.), and the items in the interactive item sequence are all historical interactive items of the object. For ease of understanding, the embodiment of the present application can refer to the interactive item sequence of each object as a historical item sequence; each object in the object collection can correspond to a historical item sequence.
[0084] After obtaining the item set, object set, and historical item sequence corresponding to each object in the object set in the business platform, a text representation can be constructed for all items in the item set and the historical item sequence corresponding to each object in the object set. The text representation construction process of the item may include but is not limited to: obtaining the item type (Category), item identification (Brand) and item name (Title) corresponding to each item in the item set, combining the item type, item identification and item name corresponding to the same item, and obtaining the text representation of each item. The text representation at this time can be called the first text representation. The item type refers to a classification method based on the attributes (e.g., color, size, shape, etc.), function, use or other characteristics of the item. For example, the items can be classified according to the characteristics such as material and use to obtain the item type corresponding to each item; the item type may include but is not limited to: clothing, electronic products, beauty, medicine, personal care and cleaning, office, beverages, etc. The item identification may refer to the brand to which the item belongs, which can be used to distinguish the specific image of a product in the market from other similar products, such as trademarks, logos, names, designs, etc. The name of an item may refer to a name (or title) used to uniquely identify or distinguish an item. The name of an item may usually be composed of at least one of factors such as manufacturer, product type, brand, model, specification, etc.
[0085] For the historical item sequence corresponding to each object in the object set, the items in the historical item sequence can be sorted in descending order according to the interaction time corresponding to the items in the historical item sequence to obtain the sorted historical item sequence; the first text representations corresponding to the items in the sorted historical item sequence are spliced to obtain the second text representation corresponding to the historical item sequence of each object. In other words, the first text representations of the items in the historical item sequence of each object can be spliced in reverse order to form the second text representation corresponding to the historical item sequence of each object, and one historical item sequence can construct one second text representation.
[0086] See also Figure 3 , Figure 3 Schematic diagram of a text representation structure provided by an embodiment of the present application. Figure 3 As shown, it is assumed that the item interaction record of object A in the business platform is: the interaction time of item 1 is t1; the interaction time of item 2 is t2, and the interaction time of item 3 is t3. If t1 is earlier than t2, and t2 is earlier than t3, then the historical item sequence of object A can be expressed as [item 1, item 2, item 3]. Among them, the first text representation 20a corresponding to item 1 can be expressed as "(type: electronic product) XX mobile phone 16GB memory 8-core processor (brand: XX)"; the first text representation 20b corresponding to item 2 can be expressed as "(type: electronic product) XX laptop i7 (brand: XX)"; the first text representation 20c corresponding to item 3 can be expressed as "(type: electronic product) mouse (brand: XX)". Then the second text representation corresponding to the historical item sequence of object A can refer to the first text representation 20c corresponding to item 3, the first text representation 20b corresponding to item 2, and the first text representation 20a corresponding to item 1, which are sequentially spliced.
[0087] Step S102: Generate a first training sample according to the second text representation, perform text prediction on the first training sample according to the pre-trained language model, and obtain a prediction probability corresponding to a hidden position in the first training sample.
[0088] Specifically, a first training sample for training a pre-trained language model can be generated through a second text representation corresponding to a historical item sequence of each object, where the first training sample may refer to an input text representation for input into the pre-trained language model; in the pre-training stage of the pre-trained language model, the pre-trained language model may be trained based on the first training sample using a dual-task strategy of a masked language modeling task and an item-item comparison task (which may be referred to as item comparison).
[0089] The construction process of the first training sample may include but is not limited to: determining the hidden position in the second text representation according to the text selection ratio, determining the text at the hidden position as the candidate text representation; performing a hiding process on the candidate text representation in the second text representation to obtain an initial sample, adding a marker text (for example, [CLS] word element, the [CLS] word element can be added at the first position of the initial sample) to the initial sample, and obtaining the first training sample. Among them, the hiding process of the candidate text representation may refer to using the first hiding probability and the second hiding probability to perform a hiding process on the candidate text representation in the second text representation to obtain an initial sample; the first hiding probability refers to the probability of replacing the candidate text representation in the second text representation with a mask (for example, [MASK] word element), and the second hiding probability refers to the probability of replacing the candidate text representation in the second text representation with a random text representation. For example, the text selection ratio in the embodiment of the present application can be set to 15%, the first hiding probability can be set to 80%, the second hiding probability can be set to 10%, etc. The embodiment of the present application can be set according to the specific requirements of the actual application scenario, and the specific settings of the above-mentioned text selection ratio, the first hiding probability, and the second selection probability are not limited.
[0090] The above-mentioned text selection ratio may refer to the hidden text selection ratio pre-set for the masked language modeling task of the pre-trained language model. For example, if the text length corresponding to the input text (such as the second text representation) of the pre-trained language model is C (C is an integer greater than 1), and the pre-set text selection ratio is p (p is any value greater than 0 and less than 1), then it can be determined that the total length of text that needs to be hidden in the masked language modeling task is C×p. The hidden position may refer to the position of the text representation selected for hidden processing in the second text representation; the candidate text representation may refer to all text representations selected for hidden processing in the second text representation; the initial sample may refer to the second text representation after the candidate text representation is hidden; the first training sample refers to the second text representation after the [CLS] word is added to the first position and the candidate text representation is hidden.
[0091] In a feasible embodiment, the text length can be represented by the number of tokens (words or word examples) contained in the text representation (for example, the second text representation). In natural language processing, a token can be understood as the smallest unit with independent meaning in a text, usually referring to a word, number, phrase, or other part with independent meaning. For example, when the length of the text that needs to be hidden in the masked language modeling task is C×p, it means that C×p tokens in the second text processing need to be hidden; therefore, the position of the token that needs to be hidden can be determined in the second text representation, that is, the hidden position in the second text representation is determined; the hidden position at this time can refer to the position of a single token, that is, each token in the second text representation can correspond to a hidden position. The above C×p tokens that need to be hidden can be randomly selected from the second text representation, and the selected C×p tokens can be called candidate text representations.
[0092] For example, the text selection ratio is 15%, the first hiding probability is 80%, and the second hiding probability is 10%. The masked language modeling task in the pre-trained language model can randomly select 15% of the tokens in the second text representation, and hide these selected tokens in the following way: ① Replace the selected token with a mask ([MASK] word) with the first hiding probability (80%); ② Replace the selected token with a random token with the second hiding rate (10%); ③ Do not change the selected token with the third hiding probability (10%). The original value of the selected token is predicted by the pre-trained language model to obtain the predicted probability corresponding to each selected token in the masked language modeling task.
[0093] In a feasible embodiment, the text length can be expressed by the number of items contained in the text representation (for example, the second text representation), or it can be understood as the number of first text representations contained in the second text representation; it should be understood that the first text representation corresponding to each item can include one or more tokens. For example, when the length of the text that needs to be hidden in the masked language modeling task is C×p, it means that the C×p first text representations in the second text processing need to be hidden; therefore, the position of the first text representation that needs to be hidden can be determined in the second text representation, that is, the hidden position in the second text representation is determined; at this time, the hidden position can refer to the position of the entire first text representation, that is, the entire first text representation in the second text representation corresponds to one hidden position. The above C×p first text representations that need to be hidden can be randomly selected from the second text representation, and the selected C×p first text representations can be called candidate text representations.
[0094] For example, the text selection ratio is 15%, the first hiding probability is 80%, and the second hiding probability is 10%. The masked language modeling task in the pre-trained language model can randomly select 15% of the first text representations in the second text representation, and hide these selected first text representations in the following way: ① Replace the selected first text representation with a mask ([MASK] word) with the first hiding probability (80%); ② Replace the selected first text representation with a random first text representation with the second hiding rate (10%); ③ Do not change the selected first text representation with the third hiding probability (10%). The original value of the selected first text representation is predicted by the pre-trained language model to obtain the predicted probability corresponding to each selected first text representation in the masked language modeling task.
[0095] In summary, in an embodiment of the present application, the masked language modeling task in the pre-trained language model can hide a single token in the second text representation, or can hide the entire first text representation in the second text representation, and the present application does not limit this.
[0096] It should be noted that before the text representation corresponding to the item or historical item sequence is input into the pre-trained language model, a special marker text (for example, [CLS] word) can be added before the text representation. The output of the marker text in the last layer of the pre-trained language model can be used as the embedding representation of the item or historical item sequence for subsequent model training and item embedding initialization. Adding the marker text is conducive to the model learning the bidirectional semantic knowledge in the historical item sequence. For example, suppose the second text representation corresponding to a historical item sequence is X1 = {T1, T2...T n}, then the second text corresponding to the historical item sequence needs to add a marker text before entering the pre-trained language model, that is, X2 = {[CLS], T1, T2...T n}; where X1 represents the second text representation corresponding to a historical item sequence, T1, T2...T n represents the first, second, ..., nth first text representation in the second text representation. The text representation after adding the marker text ([CLS] word) to the second text representation X1 is recorded as X2. Where X1 = {T1, T2...T n} and X2={[CLS],T1,T2...T n}, the interaction time of the item corresponding to T1 is later than the interaction time of the item corresponding to T2, the interaction time of the item corresponding to T2 is later than the interaction time of the item corresponding to T3, and so on. nThe corresponding item has the earliest interaction time in the entire sequence; in other words, X1 and X2 are sorted in reverse order from latest to earliest interaction time.
[0097] In a feasible embodiment, the first training sample can be predicted by a pre-trained language model to obtain the prediction probability corresponding to the hidden position in the first training sample. Optionally, if the pre-trained language model is any language model with an encoder architecture, the first training sample can be input into the encoder in the pre-trained language model, and the first training sample is encoded by the encoder to obtain the first sample embedding representation corresponding to the first training sample; the first sample embedding representation can be used to predict the prediction probability of each hidden position in the first training sample, and the prediction probability here can refer to the probability of predicting the selected candidate text representation (token or first text representation) according to the text representation in the first training sample except the hidden position in the masked language modeling task of the pre-trained language model. Among them, the encoder can be used to learn the semantic association between the first text representation in the first training sample except the hidden position, and obtain the first sample embedding representation corresponding to the first training sample. The encoder can be used to perform bidirectional encoding on the first training sample, which can improve the effectiveness of the first sample embedding representation.
[0098] Step S103: performing an object comparison between the first training sample and a first positive sample corresponding to the first training sample according to the pre-trained language model to obtain a first sample similarity.
[0099] Specifically, in the pre-training stage of the pre-trained language model, the item-item comparison task can use the first text representation corresponding to the next real interactive item of the same object in the sequence recommendation as a positive sample, and use the first text representations corresponding to other items in the same batch as negative samples; wherein the first training sample can include positive samples and negative samples. The first text representation of the subsequent interactive item corresponding to the first training sample can be determined as the first positive sample; the first training sample and the first positive sample belong to the historical interactive items of the same object, and the subsequent interactive item can refer to the next real interactive item of the first training sample in the sequence recommendation; the first positive sample is input into the pre-trained language model, and the first positive sample is encoded by the encoder in the pre-trained language model to obtain the second sample embedding representation corresponding to the first positive sample; the first object embedding representation corresponding to the object associated with the first positive sample is obtained, and the first sample similarity is obtained according to the first object embedding representation, the second sample embedding representation, and the first sample embedding representation corresponding to the first training sample.
[0100] Wherein, assuming that the number of first training samples is M, M is a positive integer; then, according to the first object embedding representation, the second sample embedding representation, and the first sample embedding representation corresponding to the first training sample, the first sample similarity is obtained, which may include but is not limited to: obtaining the first feature similarity between the first object embedding representation and the second sample embedding representation, performing an exponential operation on the first feature similarity, and obtaining a first similarity candidate value; obtaining the second feature similarity between the first object embedding representation and the first sample embedding representation corresponding to each first training sample, performing an exponential operation on the second feature similarity, and obtaining a second candidate similarity value associated with each first training sample; accumulating the second candidate similarity values associated with each first training sample to obtain a cumulative similarity value, and determining the first sample similarity according to the ratio between the first similarity candidate value and the cumulative similarity value; the first sample similarity can be used as the loss of the item-item comparison task in the pre-trained language model. Wherein, the calculation method of the first sample similarity can be shown as the following formula (1):
[0101]
[0102] Where L1 represents the first sample similarity between the first training sample and the first positive sample of the i-th training sample, i is a positive integer less than or equal to M, log represents the logarithmic function with base 10, and h s represents a first object embedding representation calculated by the pre-trained language model, where the first object embedding representation may refer to an embedding representation corresponding to an object associated with the first positive sample; represents the second sample embedding representation of the first positive sample (the first positive sample corresponding to the i-th first training sample) calculated by the pre-trained language model; i represents the first sample embedding representation of the i-th first training sample calculated by the pre-trained language model. B can be expressed as the batch size, and τ is a hyperparameter; represents the cosine similarity (first feature similarity) between the first object embedding representation and the second sample embedding representation; sim(h s ,h i ) represents the cosine similarity (second feature similarity) between the first object embedding representation and the first sample embedding representation.
[0103] Step S104: training the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model.
[0104] Specifically, assume that there are N hidden positions in the first training sample, where N is a positive integer, that is, the number of text representations selected in the second training sample is N. Perform a logarithmic operation on the predicted probabilities corresponding to the N hidden positions to obtain the logarithmic value of the probability of each hidden position, and add up the logarithmic values of the probability of each hidden position to obtain and determine the masked language modeling loss. The calculation method of the masked language modeling loss can be shown in the following formula (2):
[0105]
[0106] Wherein, L2 in formula (2) represents the masked language modeling loss, X represents the first training sample input into the pre-trained language model, and m(X) represents the set of all text representations that have been hidden in the first training sample, or can be understood as the set of text representations selected in the second text representation; represents any hidden text representation in the first training sample; X \m(x) represents the text representation without hidden processing in the first training sample, that is, the remaining text representation except m(X) in the first training sample; It represents the probability that the pre-trained language model predicts the hidden text representation (the selected token or the selected first text representation, etc.) in the first training sample, that is, the predicted probability corresponding to the hidden position.
[0107] Furthermore, the model training loss corresponding to the pre-trained language model can be determined according to the masked language modeling loss and the first sample similarity. The calculation method of the model training loss can be shown in the following formula (3):
[0108] L PT =L1+γL2 (3)
[0109] Among them, L in formula (3) PT It can be expressed as the model loss of the pre-trained language model in the pre-training stage. γ, as a hyperparameter, can be used to control the weight of the masked language modeling task.
[0110] In the pre-training stage of the pre-trained language model, the network parameters of the pre-trained language model can be iteratively trained according to the model training loss, until the model training loss meets the training end condition, the training is stopped, and the trained pre-trained language model is obtained. Among them, the training end condition here can be that the number of training times of the pre-trained language model reaches the maximum number of iterations, or it can be that the model training loss reaches the convergence condition. This application does not limit the setting of the training end condition. When the pre-trained language model reaches the training end condition, the pre-training of the pre-trained language model can be stopped, and the network parameters when the training stops can be saved, and the network parameters saved here are used as the pre-trained language model after training.
[0111] Step S105, generating a second training sample according to the second text representation, and performing an object comparison between the second training sample and a second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity.
[0112] In a feasible implementation, if resources permit, the pre-trained language model can be further adjusted in the target domain to further improve the performance of the pre-trained language model. In the fine-tuning stage of the pre-trained language model, the item-item comparison task can still be used to adjust the pre-trained language model after training. The training samples in the fine-tuning stage of the pre-trained language model can be called second training samples. The second training samples can also be generated based on the second text representation corresponding to the historical item sequence. The second training samples do not need to be hidden, and the second training samples are all negative samples, that is, the second training samples are all negative samples.
[0113] Among them, the first training sample and the second training sample can be selected according to attributes. The first training sample can refer to a text representation with generalized attributes, and the second training sample can refer to a text representation with personalized attributes. In this way, both text representations with generalized attributes and text representations with personalized attributes can be obtained, which enhances the embedded representation of the pre-trained language model in the personalized field while ensuring the generalization performance of the pre-trained language model.
[0114] The construction process of the second training sample may include but is not limited to: adding a marker text (e.g., [CLS] word) to the second text representation to obtain the second training sample, and determining the second positive sample corresponding to the second training sample; obtaining the third sample embedding representation corresponding to the second training sample through the pre-trained language model, and obtaining the fourth sample embedding representation corresponding to the second positive sample through the pre-trained language model; obtaining the second object embedding representation corresponding to the object associated with the second positive sample, and obtaining the second sample similarity according to the second object embedding representation, the third sample embedding representation, and the fourth sample embedding representation. Among them, the second training sample used in the fine-tuning stage of the pre-trained language model can be a full negative sample. After determining a second positive sample in this stage, the second training sample used to adjust the pre-trained language model can be determined in the item set. For example, the second training sample can be the first text representation corresponding to other items in the item set except the second positive sample. The calculation method of the second sample similarity can refer to the calculation method of the first sample similarity mentioned above, which will not be repeated here; the calculation method of the second sample similarity can be shown in the following formula (4):
[0115]
[0116] Among them, L FTrepresents the second sample similarity between the second training sample and the second positive sample, that is, the item comparison task loss of the pre-trained language model after training in the fine-tuning stage. log represents the logarithmic function with base 10. h in formula (4) s represents a second object embedding representation calculated by the trained pre-trained language model, where the second object embedding representation may refer to an embedding representation corresponding to an object associated with the second positive sample; I represents the fourth sample embedding representation of the second positive sample calculated by the trained pre-trained language model; i represents the third sample embedding representation of the second training sample calculated by the trained pre-trained language model. I can be expressed as the batch size, and τ is a hyperparameter; represents the cosine similarity between the second object embedding representation and the fourth sample embedding representation; sim(h s ,I i ) represents the cosine similarity between the second object embedding representation and the third sample embedding representation.
[0117] Step S106, adjusting the trained pre-trained language model according to the second sample similarity to obtain an adjusted pre-trained language model.
[0118] Specifically, in the fine-tuning stage of the pre-trained language model, the network parameters of the trained pre-trained language model can be iteratively trained according to the second sample similarity until the second sample similarity meets the training end condition, and the training is stopped to obtain the adjusted pre-trained language model. Among them, the training end condition here can be that the number of training times of the trained pre-trained language model reaches the maximum number of iterations, or it can be that the second sample similarity reaches the convergence condition. The present application does not limit the setting of the training end condition. When the trained pre-trained language model reaches the training end condition, the fine-tuning of the trained pre-trained language model can be stopped, and the network parameters at the time of training stop can be saved. The network parameters saved here are used as the adjusted pre-trained language model, and the adjusted pre-trained language model can be used to initialize the embedded representation of the object.
[0119] See also Figure 4 , Figure 4 is a training diagram of a pre-trained language model provided in an embodiment of the present application. Figure 4As shown, the training process of the pre-trained language model may include two stages, respectively denoted as a pre-training stage and a fine-tuning stage. In the pre-training stage of the pre-trained language model, the pre-trained language model may be pre-trained using the strategies of the hidden language modeling task and the item-item comparison task to obtain a trained pre-trained language model. In the fine-tuning stage of the pre-trained language model, the pre-trained language model may be adjusted using the strategy of the item-item comparison task to obtain an adjusted pre-trained language model.
[0120] In an embodiment of the present application, a first text representation corresponding to each item in an item set is obtained, and the first text representations corresponding to the items contained in the historical item sequence of each object are spliced to obtain a second text representation corresponding to the historical item sequence; a first training sample for training a pre-trained language model and a second training sample for adjusting the trained pre-trained language model are constructed according to the second text representation. Based on the first training sample, the pre-trained language model is trained using a dual-task strategy of masked language modeling (text prediction) and item comparison to obtain a trained pre-trained language model. Based on the second training sample, the pre-trained language model is adjusted using an item comparison strategy to obtain an adjusted pre-trained language model. The above-mentioned adjusted pre-trained language model can provide an initialized item embedding representation for sequence recommendation, and can make full use of the prior knowledge of the pre-trained language model to extract sequence features in the historical item sequence, thereby enhancing the effectiveness of the item embedding representation.
[0121] In the embodiment of the present application, the adjusted pre-trained language model can be used to initialize the item embedding of the general sequence recommendation model. Figure 5 , Figure 5 is a flowchart of an item embedding initialization based on a pre-trained language model provided in an embodiment of the present application; it can be understood that, Figure 5 The corresponding embodiment is the application of the adjusted pre-trained language model. Figure 5 As shown, the data processing method may include the following steps S201 to S205:
[0122] Step S201, adding a mark text to the first text representation corresponding to each item in the item set, to obtain the item input text corresponding to each item in the item set.
[0123] In the embodiment of the present application, a marker text (eg, [CLS] word) may be added to the first text representation corresponding to each item in the item set, and the item input text corresponding to each item in the item set may be obtained.
[0124] Step S202: input the item input text corresponding to item a in the item set into the adjusted pre-trained language model, and obtain the item embedding representation corresponding to item a through the adjusted pre-trained language model.
[0125] Specifically, for each item in the item set, an item input text can be obtained, and the item input text can be input into the adjusted pre-trained language model, and the adjusted pre-trained language model can output the output corresponding to the marker text (for example, [CLS] word) as the item embedding representation of the item pair. In the same way, the item embedding representation corresponding to each item in the item set can be obtained.
[0126] Step S203, obtaining the item embedding representation corresponding to each item in the item set, and adding the item embedding representation corresponding to each item to the item embedding table.
[0127] Specifically, each time an item embedding representation corresponding to an item in an item set is calculated, the item embedding representation of the item can be added to the item embedding table to initialize the item embedding table; the item embedding table can be used as an initialization sequence feature in sequence recommendation modeling.
[0128] Step S204: Generate a third training sample for the sequence recommendation model according to the item embedding representation in the item embedding table and the historical item sequence corresponding to each object in the object set.
[0129] Step S205: training the sequence recommendation model according to the third training sample to obtain a trained sequence recommendation model.
[0130] Among them, the training of the sequence recommendation model includes the first stage and the second stage. The first stage is used to train the sequence modeling task, and the training of the item embedding representation is suspended; the second stage is used to train the item embedding representation, and the training of the sequence modeling task is suspended; the trained sequence recommendation model is used for item recommendation.
[0131] After completing the initialization of the item embedding table, a two-stage training strategy can be used to train the sequence recommendation model. In the first stage, the item embedding representation in the sequence recommendation model can be frozen, and only the sequence modeling part of the model can be trained. In the second stage, the sequence modeling part of the model can be frozen, and only the item embedding representation in the model can be trained. During the training process of the sequence recommendation model, other training settings are consistent with the original general settings of the sequence recommendation model.
[0132] It is understandable that using the adjusted pre-trained language model to initialize the item embedding table in the sequence recommendation model, and using a two-stage training strategy to train the sequence recommendation model based on the initialized item embedding table is only an example provided by this application. This application can also use other strategies to train the sequence recommendation model and perform two-stage model training on the sequence recommendation model. For example, after completing the initialization of the item embedding table, the full parameters of the model can be directly trained on the data set of the target domain. Alternatively, the item representation encoded based on the adjusted pre-trained language model can be used as an additional feature of each item and frozen, added to the original item embedding representation during training and reasoning, and the full parameters in the sequence modeling model are trained on the data set of the target domain, etc. This application does not limit the training strategy of the sequence recommendation model.
[0133] See also Figure 6 , Figure 6 is a training diagram of a sequence recommendation task provided in an embodiment of the present application. Figure 6 As shown, a first text representation can be constructed for each item in the item set, and a second text representation corresponding to the historical item sequence of each object in the object set can be constructed based on the first text representation of each item. A first training sample and a second training sample are constructed based on the second text representation, and the pre-trained language model is pre-trained using the first training sample to obtain a trained pre-trained language model; the trained pre-trained language model is adjusted based on the second training sample to obtain an adjusted pre-trained language model. The item embedding table can be initialized through the adjusted pre-trained language model. Based on the initialized item embedding table, an initialization sequence feature of a sequence recommendation model can be constructed, and based on the initialization sequence feature, the sequence recommendation model is trained in two stages to obtain a trained sequence recommendation model. The trained sequence recommendation model can be iteratively trained according to the object representation output by the model; the trained sequence recommendation model can be used for item recommendation.
[0134] Please refer to Tables 1 and 2 below, which show the test results of the sequence recommendation model using the adjusted pre-trained language model to initialize the item embedding table and some other sequence recommendation models tested on different data sets (i.e., using text representations in different data sets to recommend items). Among them, other sequence recommendation models involved in the embodiments of the present application may include but are not limited to: SASRec, UniSRec (Towards Universal Sequence Representation Learning for Recommender Systems, a universal sequence representation learning model enhanced by a pre-trained language model), RECFORMER (a universal sequence representation learning model enhanced by a pre-trained language model), etc.
[0135] Table 1
[0136]
[0137]
[0138] Table 2
[0139]
[0140] Among them, this scheme refers to the sequence recommendation model provided in this application that uses the adjusted pre-trained language model to initialize the item embedding table. HR (Hit Radio) is used to evaluate the accuracy of the model in predicting recommended items. The higher the two indicators HR@1 and HR@5, the higher the accuracy of the model's recommended items. NDCG (Normalized Discounted Cumulative Gain) is used to evaluate the rationality of the recommendation order when the model recommends items. The higher the NDCG@5 indicator, the more the model can give priority to recommending items that are in line with the object's own interests.
[0141] From the results in Table 1 and Table 2 above, it can be seen that the performance of this scheme is better than UniSRec and RECFORMER in almost all data sets. At the same time, after using the pre-trained language model proposed in this application to initialize the item embedding table, the performance of SASRec and BERT4Rec in the sequence recommendation task has been greatly improved. The above experimental results fully demonstrate the effectiveness of this scheme.
[0142] The embodiment of the present application initializes the item embedding representation through the adjusted pre-trained language model, so that the text information and sequence features can be better aligned, and the historical item interaction sequence features can be accurately extracted while fully utilizing the prior knowledge of the pre-trained language model, thereby enhancing the effectiveness of the item embedding representation, and further improving the recommendation effect of the sequence recommendation model.
[0143] It is understandable that in the specific implementation of this application, interactive information such as the user's item purchase records in the shopping platform may be involved. When the above embodiments of this application are applied to specific products or technologies, it is necessary to obtain the permission or consent of the relevant institutions or departments, or the users themselves, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant regions.
[0144] See also Figure 7 , Figure 7 Schematic diagram of a data processing device provided in an embodiment of the present application. Figure 7 As shown, the data processing device 1 includes: a text acquisition module 101, a text prediction module 102, a first object comparison module 103, a model pre-training module 104, a second object comparison module 105, and a model adjustment module 106;
[0145] A text acquisition module 101 is used to acquire a first text representation corresponding to each item in the item set, and acquire a second text representation corresponding to the historical item sequence of each object in the object set based on the first text representation;
[0146] A text prediction module 102 is used to generate a first training sample according to the second text representation, perform text prediction on the first training sample according to the pre-trained language model, and obtain a prediction probability corresponding to a hidden position in the first training sample; the first training sample includes a positive sample and a negative sample;
[0147] A first object comparison module 103 is used to compare the first training sample with a first positive sample corresponding to the first training sample according to the pre-trained language model to obtain a first sample similarity;
[0148] A model pre-training module 104 is used to train the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model;
[0149] A second object comparison module 105 is used to generate a second training sample according to the second text representation, and to compare the second training sample with a second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity; the second training sample does not contain the positive sample;
[0150] The model adjustment module 106 is used to adjust the trained pre-trained language model according to the second sample similarity to obtain an adjusted pre-trained language model; the adjusted pre-trained language model is used to initialize the embedded representation of the object.
[0151] In one or more embodiments, the text acquisition module 101 acquires a first text representation corresponding to each item in the item set, and acquires a second text representation corresponding to the historical item sequence of each object in the object set according to the first text representation, so as to perform the following steps:
[0152] Obtaining an item type, an item identifier, and an item name corresponding to each item in the item set, and combining the item type, item identifier, and item name corresponding to the same item to obtain a first text representation corresponding to each item;
[0153] Obtaining a historical item sequence corresponding to each object in the object set, and sorting the items in the historical item sequence in descending order according to the interaction time corresponding to the items in the historical item sequence, to obtain a sorted historical item sequence;
[0154] The first text representations corresponding to the items included in the sorted historical item sequence are concatenated to obtain the second text representations corresponding to the historical item sequence of each object.
[0155] In one or more embodiments, the text prediction module 102 generates a first training sample according to the second text representation, for performing the following steps:
[0156] Determine a hidden position in the second text representation according to the text selection ratio, and determine the text in the hidden position as a candidate text representation;
[0157] The candidate text representation in the second text representation is subjected to hiding processing to obtain an initial sample, and a marker text is added to the initial sample to obtain a first training sample.
[0158] In one or more embodiments, the text prediction module 102 performs hidden processing on the candidate text representation in the second text representation to obtain an initial sample for performing the following steps:
[0159] Using the first hiding probability and the second hiding probability, hiding the candidate text representation in the second text representation to obtain an initial sample;
[0160] The first hiding probability refers to the probability of replacing the candidate text representation in the second text representation with the mask, and the second hiding probability refers to the probability of replacing the candidate text representation in the second text representation with the random text representation.
[0161] In one or more embodiments, the pre-trained language model includes an encoder and a decoder;
[0162] The text prediction module 102 performs text prediction on the first training sample according to the pre-trained language model to obtain the prediction probability corresponding to the hidden position in the first training sample, which is used to perform the following steps:
[0163] Inputting the first training sample into the pre-trained language model, encoding the first training sample through the pre-trained language model, and obtaining a first sample embedding representation corresponding to the first training sample;
[0164] Perform text prediction on the hidden position in the first training sample according to the first sample embedding representation to obtain a prediction probability corresponding to the hidden position in the first training sample.
[0165] In one or more embodiments, the first item comparison module 103 performs an item comparison on the first training sample and the first positive sample corresponding to the first training sample according to the pre-trained language model to obtain a first sample similarity for performing the following steps:
[0166] The first text representation of the subsequent interaction item corresponding to the first training sample is determined as the first positive sample; the first training sample and the first positive sample are historical interaction items of the same object;
[0167] Inputting the first positive sample into the pre-trained language model, encoding the first positive sample through the encoder in the pre-trained language model, and obtaining a second sample embedding representation corresponding to the first positive sample;
[0168] A first object embedding representation corresponding to the object associated with the first positive sample is obtained, and a first sample similarity is obtained according to the first object embedding representation, the second sample embedding representation, and the first sample embedding representation corresponding to the first training sample.
[0169] In one or more embodiments, the number of first training samples is M, where M is a positive integer;
[0170] The first object comparison module 103 obtains a first sample similarity according to the first object embedding representation, the second sample embedding representation, and the first sample embedding representation corresponding to the first training sample, and is used to perform the following steps:
[0171] Obtaining a first feature similarity between the first object embedding representation and the second sample embedding representation, performing an exponential operation on the first feature similarity, and obtaining a first similarity candidate value;
[0172] Obtaining a second feature similarity between the first object embedding representation and the first sample embedding representation corresponding to each first training sample, performing an exponential operation on the second feature similarity, and obtaining a second candidate similarity value associated with each first training sample;
[0173] The second candidate similarity values associated with each first training sample are accumulated to obtain a cumulative similarity value, and the first sample similarity is determined according to a ratio between the first similarity candidate value and the cumulative similarity value.
[0174] In one or more embodiments, the number of hidden positions in the first training sample is N, where N is a positive integer;
[0175] The model pre-training module 104 trains the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model for performing the following steps:
[0176] Perform logarithmic operation on the predicted probabilities corresponding to the N hidden positions to obtain the logarithmic value of the probability of each hidden position, and accumulate the logarithmic values of the probability of each hidden position to obtain and determine the masked language modeling loss;
[0177] Determine a model training loss corresponding to the pre-trained language model according to the masked language modeling loss and the first sample similarity;
[0178] According to the model training loss, the network parameters of the pre-trained language model are iteratively trained until the model training loss meets the training end condition, then the training is stopped to obtain the trained pre-trained language model.
[0179] In one or more embodiments, the second item comparison module 105 generates a second training sample according to the second text representation, and performs an item comparison on the second training sample and a second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity for performing the following steps:
[0180] Adding a marker text to the second text representation to obtain a second training sample, and determining a second positive sample corresponding to the second training sample;
[0181] Obtain a third sample embedding representation corresponding to the second training sample through the pre-trained language model, and obtain a fourth sample embedding representation corresponding to the second positive sample through the pre-trained language model;
[0182] A second object embedding representation corresponding to the object associated with the second positive sample is obtained, and a second sample similarity is obtained according to the second object embedding representation, the third sample embedding representation, and the fourth sample embedding representation.
[0183] In one or more embodiments, the data processing device 1 may further include: an item input text acquisition module 107, an item embedding representation acquisition module 108, and an item embedding table generation module 109;
[0184] An item input text acquisition module 107, configured to add a marker text to the first text representation corresponding to each item in the item set, to obtain an item input text corresponding to each item in the item set;
[0185] An item embedding representation acquisition module 108 is used to input the item input text corresponding to item a in the item set into the adjusted pre-trained language model, and acquire the item embedding representation corresponding to item a through the adjusted pre-trained language model;
[0186] The item embedding table generating module 109 is used to obtain the item embedding representation corresponding to each item in the item set, and add the item embedding representation corresponding to each item to the item embedding table.
[0187] In one or more embodiments, the data processing device 1 may further include: a training sample generating module 110, a recommendation model training module 111;
[0188] A training sample generating module 110, configured to generate a third training sample of the sequence recommendation model according to the item embedding representation in the item embedding table and the historical item sequence corresponding to each object in the object set;
[0189] A recommendation model training module 111 is used to train the sequence recommendation model according to the third training sample to obtain a trained sequence recommendation model;
[0190] Among them, the training of the sequence recommendation model includes the first stage and the second stage. The first stage is used to train the sequence modeling task, and the training of the item embedding representation is suspended; the second stage is used to train the item embedding representation, and the training of the sequence modeling task is suspended; the trained sequence recommendation model is used for item recommendation.
[0191] According to an embodiment of the present application, the above Figure 2 The steps involved in the data processing method shown can be represented by Figure 7 The data processing device 1 shown in the figure is executed by each module. For example, Figure 2 Step S101 shown can be performed by Figure 7 The text acquisition module 101 shown is used to execute, Figure 2 Step S102 shown can be performed by Figure 7 The text prediction module 102 shown is used to perform, Figure 2 Step S103 shown can be performed by Figure 7 The first item comparison module 103 is shown to execute, Figure 2 Step S104 shown can be performed by Figure 7 The model pre-training module 104 shown is used to perform, Figure 2 Step S105 shown can be performed by Figure 7The second item comparison module 105 is shown to execute, Figure 2 Step S106 shown can be performed by Figure 7 The model adjustment module 106 shown is used to perform the following operations.
[0192] According to one embodiment of the present application, Figure 7 The various modules in the data processing device 1 shown can be separately or all combined into one or several modules to constitute, or one (some) of the modules can be further divided into at least two smaller units in function, and the same operation can be achieved without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In practical applications, the function of one module can also be implemented by at least two units, or the functions of at least two modules can be implemented by one module. In other embodiments of the present application, the data processing device 1 may also include other modules or units. In practical applications, these functions can also be implemented with the assistance of other modules, and can be implemented by the collaboration of at least two modules.
[0193] In an embodiment of the present application, a first text representation corresponding to each item in an item set is obtained, and the first text representations corresponding to the items contained in the historical item sequence of each object are spliced to obtain a second text representation corresponding to the historical item sequence; a first training sample for training a pre-trained language model and a second training sample for adjusting the trained pre-trained language model are constructed according to the second text representation. Based on the first training sample, the pre-trained language model is trained using a dual-task strategy of masked language modeling (text prediction) and item comparison to obtain a trained pre-trained language model. Based on the second training sample, the pre-trained language model is adjusted using an item comparison strategy to obtain an adjusted pre-trained language model. The above-mentioned adjusted pre-trained language model can provide an initialized item embedding representation for sequence recommendation, and can make full use of the prior knowledge of the pre-trained language model to extract sequence features in the historical item sequence, thereby enhancing the effectiveness of the item embedding representation; the item embedding table of the sequence recommendation model is initialized by the adjusted pre-trained language model, which can improve the recommendation effect of the sequence recommendation model.
[0194] See also Figure 8 , Figure 8 Schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 8 As shown, the computer device 1000 may be a terminal device, for example, Figure 1 The terminal device 10a in the corresponding embodiment may also be a server, for example, Figure 1The server 10d in the corresponding embodiment will not be limited here. For ease of understanding, this application takes a computer device as an example of a terminal device. The computer device 1000 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the computer device 1000 may also include: a user interface 1003, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As Figure 8 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.
[0195] The network interface 1004 in the computer device 1000 can also provide a network communication function, and the optional user interface 1003 can also include a display screen (Display) and a keyboard (Keyboard). Figure 8 In the computer device 1000 shown, the network interface 1004 can provide a network communication function; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:
[0196] Obtain a first text representation corresponding to each item in the item set, and obtain a second text representation corresponding to the historical item sequence of each object in the object set based on the first text representation;
[0197] Generate a first training sample according to the second text representation, perform text prediction on the first training sample according to the pre-trained language model, and obtain a prediction probability corresponding to a hidden position in the first training sample; the first training sample includes a positive sample and a negative sample;
[0198] According to the pre-trained language model, an object comparison is performed between the first training sample and a first positive sample corresponding to the first training sample to obtain a first sample similarity;
[0199] Training the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model;
[0200] Generate a second training sample according to the second text representation, and perform an item comparison on the second training sample and the second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity; the second training sample does not contain the positive sample;
[0201] The trained pre-trained language model is adjusted according to the second sample similarity to obtain an adjusted pre-trained language model; the adjusted pre-trained language model is used to initialize the embedding representation of the object.
[0202] It should be understood that the computer device 1000 described in the embodiment of the present application can execute the above Figure 2 , Figure 5 The description of the data processing method in any of the embodiments may also be performed as described above. Figure 7 The description of the data processing device 1 in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated here either.
[0203] In addition, it should be pointed out that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the data processing device 1 mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the above-mentioned Figure 2 , Figure 5 The description of the data processing method in any of the embodiments will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, program instructions can be deployed on a computer device for execution, or on multiple computer devices located at one location, or on multiple computer devices distributed at multiple locations and interconnected by a communication network. Multiple computer devices distributed at multiple locations and interconnected by a communication network can constitute a blockchain system.
[0204] In addition, it should be noted that: the embodiment of the present application also provides a computer program product or a computer program, which may include computer instructions, and the computer instructions may be stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor may execute the computer instructions, so that the computer device executes the above Figure 2 , Figure 5The description of the data processing method in any of the embodiments will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer program product or computer program embodiment involved in the present application, please refer to the description of the method embodiment of the present application.
[0205] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different media contents, rather than to describe a specific order. In addition, the term "comprising" and any variation thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment comprising a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other step units inherent to these processes, methods, devices, products, or equipment.
[0206] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0207] The method and related apparatus provided by the embodiment of the present application are described with reference to the method flow chart and / or structural diagram provided by the embodiment of the present application. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or structures Figure 1These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0208] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0209] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method, characterized in that: include: Acquire a first text representation corresponding to each item in the item set, and acquire a second text representation corresponding to the historical item sequence of each object in the object set based on the first text representation; Generate a first training sample according to the second text representation, perform text prediction on the first training sample according to the pre-trained language model, and obtain a prediction probability corresponding to a hidden position in the first training sample; The first training samples include positive samples and negative samples; According to the pre-trained language model, performing an object comparison between the first training sample and a first positive sample corresponding to the first training sample to obtain a first sample similarity; Training the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model; generating a second training sample according to the second text representation, and performing an item comparison between the second training sample and a second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity; the second training sample does not contain a positive sample; The trained pre-trained language model is adjusted according to the second sample similarity to obtain an adjusted pre-trained language model; the adjusted pre-trained language model is used to initialize the embedded representation of the object.
2. The method according to claim 1, characterized in that: The step of obtaining a first text representation corresponding to each item in the item set, and obtaining a second text representation corresponding to a historical item sequence of each object in the object set according to the first text representation, includes: Obtaining an item type, an item identifier, and an item name corresponding to each item in the item set, and combining the item type, item identifier, and item name corresponding to the same item to obtain a first text representation corresponding to each item; Acquire a historical item sequence corresponding to each object in the object set, and sort the items in the historical item sequence in descending order according to the interaction time corresponding to the items in the historical item sequence to obtain a sorted historical item sequence; The first text representations corresponding to the items included in the sorted historical item sequence are concatenated to obtain the second text representations corresponding to the historical item sequence of each object.
3. The method according to claim 1, characterized in that The step of generating a first training sample according to the second text representation comprises: Determine a hidden position in the second text representation according to the text selection ratio, and determine the text in the hidden position as a candidate text representation; The candidate text representations in the second text representation are subjected to hiding processing to obtain an initial sample, and a marker text is added to the initial sample to obtain a first training sample.
4. The method according to claim 3, characterized in that The step of performing a hiding process on the candidate text representation in the second text representation to obtain an initial sample includes: Using the first hiding probability and the second hiding probability, hiding the candidate text representation in the second text representation to obtain an initial sample; The first hiding probability refers to the probability of replacing the candidate text representation in the second text representation with a mask, and the second hiding probability refers to the probability of replacing the candidate text representation in the second text representation with a random text representation.
5. The method according to claim 1, characterized in that The performing text prediction on the first training sample according to the pre-trained language model to obtain the prediction probability corresponding to the hidden position in the first training sample includes: Inputting the first training sample into the pre-trained language model, encoding the first training sample through the pre-trained language model, and obtaining a first sample embedding representation corresponding to the first training sample; Perform text prediction on the hidden position in the first training sample according to the first sample embedding representation to obtain a prediction probability corresponding to the hidden position in the first training sample.
6. The method according to claim 5, characterized in that The step of performing an object comparison on the first training sample and a first positive sample corresponding to the first training sample according to the pre-trained language model to obtain a first sample similarity includes: Determine a first text representation of a subsequent interactive item corresponding to the first training sample as a first positive sample; the first training sample and the first positive sample are historical interactive items of the same object; Inputting the first positive sample into the pre-trained language model, encoding the first positive sample through an encoder in the pre-trained language model, and obtaining a second sample embedding representation corresponding to the first positive sample; A first object embedding representation corresponding to the object associated with the first positive sample is obtained, and a first sample similarity is obtained according to the first object embedding representation, the second sample embedding representation, and the first sample embedding representation corresponding to the first training sample.
7. The method according to claim 6, characterized in that The number of the first training samples is M, where M is a positive integer; The obtaining a first sample similarity according to the first object embedding representation, the second sample embedding representation, and the first sample embedding representation corresponding to the first training sample includes: Obtaining a first feature similarity between the first object embedding representation and the second sample embedding representation, performing an exponential operation on the first feature similarity, and obtaining a first similarity candidate value; Obtaining a second feature similarity between the first object embedding representation and the first sample embedding representation corresponding to each first training sample, performing an exponential operation on the second feature similarity, and obtaining a second candidate similarity value associated with each first training sample; The second candidate similarity values associated with each first training sample are accumulated to obtain a cumulative similarity value, and the first sample similarity is determined according to a ratio between the first similarity candidate values and the cumulative similarity value.
8. The method according to claim 1, characterized in that The number of hidden positions in the first training sample is N, where N is a positive integer; The step of training the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model includes: Perform logarithmic operation on the predicted probabilities corresponding to the N hidden positions to obtain the logarithmic value of the probability of each hidden position, and accumulate the logarithmic values of the probability of each hidden position to obtain and determine the masked language modeling loss; Determining a model training loss corresponding to the pre-trained language model according to the masked language modeling loss and the first sample similarity; According to the model training loss, the network parameters of the pre-trained language model are iteratively trained until the model training loss meets the training end condition, and the training is stopped to obtain a trained pre-trained language model.
9. The method according to claim 1, characterized in that: The step of generating a second training sample according to the second text representation and performing an item comparison between the second training sample and a second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity includes: Adding a marker text to the second text representation to obtain a second training sample, and determining a second positive sample corresponding to the second training sample; Acquire a third sample embedding representation corresponding to the second training sample through the pre-trained language model, and acquire a fourth sample embedding representation corresponding to the second positive sample through the pre-trained language model; A second object embedding representation corresponding to the object associated with the second positive sample is obtained, and a second sample similarity is obtained according to the second object embedding representation, the third sample embedding representation, and the fourth sample embedding representation.
10. The method according to claim 1, characterized in that The method further comprises: Adding a marker text to the first text representation corresponding to each item in the item set to obtain an item input text corresponding to each item in the item set; Inputting an item input text corresponding to item a in the item set into the adjusted pre-trained language model, and obtaining an item embedding representation corresponding to item a through the adjusted pre-trained language model; Obtain an item embedding representation corresponding to each item in the item set, and add the item embedding representation corresponding to each item to the item embedding table.
11. The method according to claim 10, characterized in that The method further comprises: generating a third training sample of a sequence recommendation model according to the item embedding representation in the item embedding table and the historical item sequence corresponding to each object in the object set; Training the sequence recommendation model according to the third training sample to obtain a trained sequence recommendation model; The training of the sequence recommendation model includes a first stage and a second stage. The first stage is used to train the sequence modeling task, and the training of the item embedding representation is suspended. The second stage is used to train the item embedding representation, and the training of the sequence modeling task is suspended. The trained sequence recommendation model is used for item recommendation.
12. A data processing device, characterized in that: include: A text acquisition module, used to acquire a first text representation corresponding to each item in the item set, and acquire a second text representation corresponding to the historical item sequence of each object in the object set according to the first text representation; A text prediction module, configured to generate a first training sample according to the second text representation, perform text prediction on the first training sample according to a pre-trained language model, and obtain a prediction probability corresponding to a hidden position in the first training sample; The first training samples include positive samples and negative samples; A first item comparison module, configured to perform an item comparison on the first training sample and a first positive sample corresponding to the first training sample according to the pre-trained language model to obtain a first sample similarity; A model pre-training module, used for training the pre-trained language model according to the prediction probability, the hidden position in the first training sample, and the first sample similarity to obtain a trained pre-trained language model; A second item comparison module is used to generate a second training sample according to the second text representation, and perform an item comparison on the second training sample and a second positive sample corresponding to the second training sample according to the trained pre-trained language model to obtain a second sample similarity; the second training sample does not contain a positive sample; A model adjustment module is used to adjust the trained pre-trained language model according to the second sample similarity to obtain an adjusted pre-trained language model; the adjusted pre-trained language model is used to initialize the embedded representation of the object.
13. A computer device, characterized in that: including memory and processor; The memory is connected to the processor, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 11.
15. A computer program product, characterized in that The method comprises a computer program / instruction, which implements the method according to any one of claims 1 to 11 when executed by a processor.
Citation Information
Patent Citations
Language model pre-training method, result recommendation method and related device
CN114565104A
Judicial domain depth event extraction method fusing multi-task and multi-label learning
CN114580428A
Model construction method and system for enhancing medical statement semantic vector representation
CN115545041A
Knowledge enhancement pre-training language model training method and device, and knowledge enhancement pre-training language model application method and device
CN116451778A
Article recommendation method and device based on artificial intelligence, equipment and storage medium
CN117217858A
Cited By
Data processing method and apparatus, device and medium
WO2025201134A1
