Language model pre-training method and device, medium and electronic equipment

By extracting fields in structured text and generating identifier sequences for pre-training, the problem of loss of feature relationships and distribution information in the existing technology is solved, and the accuracy of the language model is improved.

CN118690848APending Publication Date: 2024-09-24ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410703975.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

In the existing technology, when pre-training language models, structured text data is directly converted into numerical vectors, resulting in the loss of potential relationships and distribution information between features, resulting in poor model performance.

Method used

By extracting each field in the structured text, determine the identifier based on the field attributes and attribute values, generate an identifier sequence, and input it into the language model for pre-training to learn feature associations and potential relationships.

Benefits of technology

Improved accuracy of language models, allowing them to better learn and understand feature associations and underlying relationships in structured text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690848A
    Figure CN118690848A
Patent Text Reader

Abstract

The invention discloses a language model pre-training method and device, a medium and electronic equipment, a first sample text can be obtained, the first sample text is a structured text, and each field in the first sample text is extracted. And for each extracted field, determining an identifier corresponding to the field according to the attribute and the attribute value of the field, and obtaining an identifier sequence corresponding to the first sample text according to the determined identifier corresponding to each field. And inputting the identifier sequence into a language model to obtain a text feature corresponding to the identifier sequence, and pre-training a coding end in the language model according to the text feature and a preset training task. According to the method, the fields in the structured text are replaced by using the identifiers, and then the language model is trained by using the identifier sequence corresponding to the structured text, so that the language model obtained by training can learn the association relationship and potential relationship of the features in the structured text, and the accuracy of the language model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular to a method, device, medium and electronic device for pre-training a language model. Background Art

[0002] With the development of science and technology, privacy data has received increasing attention. With the development of science and technology, artificial intelligence has developed rapidly. Among them, natural language processing (NLP) has received widespread attention. Natural language processing studies various theories and methods for effective communication between humans and computers through natural language.

[0003] Generally, when pre-training a language model, the text data is first converted into an embedding vector, and then the language model is pre-trained based on the embedding vector and pre-training tasks such as contrastive learning tasks, so that the language model learns the semantic features of the language and the association between word segments, etc. However, for structured text data, such as tabular data, since structured text includes multiple types of features, such as gender, amount, age, etc., these features may be independent of each other and may have complex relationships, and the importance of the features of structured text is generally unrelated to the contextual position of the word segmentation in the text. Therefore, when pre-training a language model, directly converting the structured text into a numerical vector will lose the potential relationship between the features of the structured text and the distribution information within the features, resulting in poor results for the pre-trained language model.

[0004] Based on this, this application specification provides a method for pre-training a language model. Summary of the invention

[0005] This specification provides a language model pre-training method and device, storage medium and electronic device to at least partially solve the above-mentioned problems existing in the prior art.

[0006] This manual adopts the following technical solutions:

[0007] This specification provides a pre-training method for a language model, the language model comprising: an encoding end; the method comprising:

[0008] Obtaining a first sample text; the first sample text is a structured text;

[0009] Extracting each field in the first sample text;

[0010] For each extracted field, determine the identifier corresponding to the field according to the attributes and attribute values ​​of the field;

[0011] Obtaining an identifier sequence corresponding to the first sample text according to the determined identifiers corresponding to the fields;

[0012] Inputting the identifier sequence into the language model to obtain text features corresponding to the identifier sequence;

[0013] The encoding end in the language model is pre-trained according to the text features and the preset training tasks.

[0014] Optionally, the language model further includes: an embedding layer;

[0015] Inputting the identifier sequence into the language model to obtain text features corresponding to the identifier sequence specifically includes:

[0016] Inputting the identifier sequence into the embedding layer to obtain embedding features corresponding to the identifier sequence;

[0017] The embedded features are input into the encoding end to obtain text features corresponding to the identifier sequence.

[0018] Optionally, determining an identifier corresponding to the field according to the attributes and attribute values ​​of the field includes:

[0019] According to the attribute of the field, determine an identifier set corresponding to the field, each identifier in the identifier set having a preset corresponding relationship with each attribute value range of the attribute;

[0020] According to the attribute value of the field, an identifier corresponding to the field is determined in the identifier set.

[0021] Optionally, the language model further includes: a decoding end;

[0022] Inputting the identifier sequence into the language model specifically includes:

[0023] Processing the identifier sequence by masking, and inputting the masked identifier sequence into the language model;

[0024] According to the text features and the preset training tasks, the encoding end in the language model is pre-trained, specifically including:

[0025] Inputting the text feature into the decoding end to obtain a predicted text output by the decoding end, wherein the predicted text is obtained by restoring the identifier sequence after the masking process by the decoding end based on the text feature;

[0026] The encoding end is trained with the goal of minimizing the difference between the predicted text and the identifier text sequence.

[0027] Optionally, extracting each field in the first sample text specifically includes:

[0028] According to the attributes and attribute values ​​corresponding to the first sample text, normalizing the attribute values ​​corresponding to the first sample text to obtain a normalized first sample text;

[0029] Extract each field in the first sample text after the normalization process.

[0030] Optionally, the method further comprises:

[0031] Acquire product information of a product and user information of a user, and use the product information and the user information as a second sample text; and acquire a label corresponding to the second sample text, the label indicating whether to recommend the product to the user;

[0032] The pre-trained language model is fine-tuned according to the second sample text and the annotation corresponding to the second sample text to obtain a trained language model.

[0033] Optionally, fine-tuning the pre-trained language model according to the second sample text and the annotation corresponding to the second sample text specifically includes:

[0034] Inputting the second sample text into the pre-trained language model to obtain an output result;

[0035] Determining a loss according to the output result and the annotation corresponding to the second sample text;

[0036] According to the loss, the parameters of the language model obtained by pre-training are adjusted.

[0037] This specification provides a pre-training device for a language model, the language model comprising: an encoding end; comprising:

[0038] An acquisition module, used for acquiring a first sample text; the first sample text is a structured text;

[0039] An extraction module, used for extracting each field in the first sample text;

[0040] A first determination module is used to determine, for each extracted field, an identifier corresponding to the field according to the attribute and attribute value of the field;

[0041] A second determination module, configured to obtain an identifier sequence corresponding to the first sample text according to the determined identifiers corresponding to the fields;

[0042] An input module, used for inputting the identifier sequence into the language model to obtain text features corresponding to the identifier sequence;

[0043] The first training module is used to pre-train the encoding end in the language model according to the text features and the preset training tasks.

[0044] Optionally, the language model further includes: an embedding layer;

[0045] The input module is specifically used to input the identifier sequence into the embedding layer to obtain the embedding features corresponding to the identifier sequence; and input the embedding features into the encoding end to obtain the text features corresponding to the identifier sequence.

[0046] Optionally, the first determination module is specifically used to determine, based on the attributes of the field, a set of identifiers corresponding to the field, each identifier in the set of identifiers having a preset correspondence with each attribute value range of the attribute; and to determine, based on the attribute value of the field, in the set of identifiers, an identifier corresponding to the field.

[0047] Optionally, the language model further includes: a decoding end;

[0048] The input module is specifically used to process the identifier sequence through masking, and input the identifier sequence after masking into the language model;

[0049] The first training module is specifically used to input the text features into the decoding end to obtain the predicted text output by the decoding end, wherein the predicted text is obtained by the decoding end restoring the identifier sequence after masking based on the text features; and the encoding end is trained with the goal of minimizing the difference between the predicted text and the identifier text sequence.

[0050] Optionally, the extraction module is specifically used to normalize the attribute values ​​corresponding to the first sample text according to the attributes and attribute values ​​corresponding to the first sample text to obtain the normalized first sample text; and extract each field in the normalized first sample text.

[0051] Optionally, the device further comprises a second training module;

[0052] The second training module is specifically used to obtain product information of a product and user information of a user, and use the product information and the user information as a second sample text; and obtain a label corresponding to the second sample text, wherein the label indicates whether the product is recommended to the user; and fine-tune the pre-trained language model according to the second sample text and the label corresponding to the second sample text to obtain a trained language model.

[0053] Optionally, the second training module is specifically used to input the second sample text into the pre-trained language model to obtain an output result; determine the loss based on the output result and the annotation corresponding to the second sample text; and adjust the parameters of the pre-trained language model based on the loss.

[0054] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the pre-training method of the above-mentioned language model is implemented.

[0055] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned language model pre-training method when executing the program.

[0056] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:

[0057] In the pre-training method of the language model provided in this specification, a first sample text may be obtained first, the first sample text is a structured text, and each field in the first sample text is extracted. Then, for each extracted field, an identifier corresponding to the field is determined according to the attributes and attribute values ​​of the field, and an identifier sequence corresponding to the first sample text is obtained according to the determined identifiers corresponding to each field. Finally, the identifier sequence is input into the language model to obtain text features corresponding to the identifier sequence, so as to pre-train the encoding end in the language model according to the text features and the preset training tasks.

[0058] It can be seen from the above method that by processing each field in the structured text, using identifiers to replace each field, and then using the identifier sequence corresponding to the structured text to train the language model, the trained language model can learn the correlation and potential relationship of the features in the structured text, thereby improving the accuracy of the language model. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The exemplary embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification.

[0060] In the figure:

[0061] Figure 1 A flowchart of a method for pre-training a language model in this specification;

[0062] Figure 2 A schematic diagram of the structure of a language model provided in this manual;

[0063] Figure 3 A schematic diagram of the structure of a language model provided in this manual;

[0064] Figure 4 A schematic diagram of a pre-training device for a language model provided in this specification;

[0065] Figure 5 The corresponding Figure 1 Schematic diagram of electronic equipment. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this application will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in the specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0067] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0068] Figure 1 A flow chart of a method for pre-training a language model provided in this specification may include the following steps:

[0069] S100: Acquire a first sample text; the first sample text is a structured text.

[0070] S102: extracting each field in the first sample text.

[0071] The execution subject of the technical solution of this specification can be any computing device with computing capabilities (such as a server, terminal, etc.). For the sake of ease of description, the technical solution of this specification is described below using only a server as an example.

[0072] In this specification, the server may first obtain a first sample text, where the first sample text is a structured text.

[0073] As shown in Table 1, Table 1 is the structured text data provided in the specification of this application.

[0074] User A 20 3000 User B 35 500 … … …

[0075] Table 1

[0076] Table 1 may be user data stored on a platform. The first column of Table 1 may be the user's account name, the second column may be the user's age, and the third column may be the user's average daily spending amount. In this specification, the sample text may be a piece of user data in the table, that is, "User A, 20, 3000", or, of course, multiple pieces of user data.

[0077] Generally speaking, for structured text, that is, the data shown in Table 1 above, for the segmented words in the structured text, the degree of association between the segmented words and the relative position of the segmented words in the text are not very related. For example, in Table 1, users A and 20, although "user A" and "20" are very close, there is no semantic connection between the two. For unstructured text, such as "the weather is very sunny", whether it is "sky" and "air", or "weather" and "sunny", etc., there is a semantic association, that is, the semantic relationship of the segmented words in the text can be determined according to the context. It can be seen that for structured text, the association between segmented words in structured text is generally independent of position.

[0078] Moreover, there are many types of features in structured texts. For example, "20" and "3000" are both numbers, but "20" and "3000" have different attributes, that is, the former refers to age, and the latter refers to the amount. For structured texts, it is impossible to directly reflect from the text: "20" is the age of user A, and "3000" is the average daily consumption amount of user A. Therefore, if structured text is used directly to train a language model, the potential relationship between features and the distribution information within the features will be lost, making the trained language model inaccurate.

[0079] After the server obtains the first sample text, that is, the structured text, each field in the first sample text may be extracted.

[0080] In one or more embodiments of the present specification, the server may determine the fields in the first sample text through a pre-trained artificial intelligence model for extracting fields in text, or may obtain the fields in the first sample text through manual extraction, etc. The present specification does not limit the specific method used to extract the fields in the first sample text.

[0081] S104: For each extracted field, determine an identifier corresponding to the field according to the attributes and attribute values ​​of the field.

[0082] S106: Obtain an identifier sequence corresponding to the first sample text according to the determined identifiers corresponding to the fields.

[0083] After the server extracts each field in the structured text, it can also determine an identifier of each extracted field according to the attributes and attribute values ​​of the field.

[0084] Specifically, in one or more embodiments of the present specification, the server may determine the identifier set corresponding to the field according to the attribute of the field, and then determine the identifier corresponding to the field in the identifier set corresponding to the field according to the attribute value of the field. Each identifier in the identifier set corresponding to the field corresponds to each attribute value range of the attribute of the field, and the correspondence is preset. In other words, each field corresponds to an identifier set, and each identifier in the identifier set is used to identify a different attribute value range. For example: Using the above Table 1, assuming that the first sample text currently used is: "User A, 20, 3000", it can be known that the attribute of "20" is age, and the attribute of "3000" is the average daily consumption amount. It is further assumed that the preset age identifier set is "a, b, c", and "a" corresponds to the range "0-30" years old, "b" corresponds to the range "31-60" years old, and "c" corresponds to the range "over 60 years old". The preset identifier set of the average daily consumption amount is "x, y, z", and "x" corresponds to the range of "0-1000" yuan, "y" corresponds to the range of "1001-2000" yuan, and "z" corresponds to the range of "more than 2000 yuan". It can be determined that the identifier corresponding to the field "20" in the first sample text "User A, 20, 3000" is "a", and the identifier corresponding to the field "3000" is "z".

[0085] Then, the server can obtain the identifier sequence corresponding to the first sample text according to the determined identifiers corresponding to the fields. Using the above example, it can be seen that the identifier sequence corresponding to the first sample text "User A, 20, 3000" is "User Aaz".

[0086] In one or more embodiments of this specification, a corresponding identifier set may be pre-set for each field, or only identifier sets may be set for some fields. For example, in the above example, the attribute of the user's account name in the first sample text "User A, 20, 3000" is not pre-set with an identifier set, while the age and the average daily consumption amount are pre-set with an identifier set. In this specification, an identifier set may be set for an attribute whose attribute value is continuous data, and no identifier set may be set for an attribute whose attribute value is non-continuous data.

[0087] In one or more embodiments of the present specification, the form of the identifier is not limited, and it can be Arabic numerals, letters, Roman numerals, etc., without specific limitation, as long as each identifier can uniquely identify its corresponding attribute value range.

[0088] The above method of replacing fields in structured text by using identifiers allows different attribute values ​​of the same attribute in the structured text to use the same identifier, thereby giving association information between fields in the structured text, so that in subsequent steps, the language model can better learn the differences and connections between fields in the structured text.

[0089] S108: Input the identifier sequence into the language model to obtain text features corresponding to the identifier sequence.

[0090] S110: Pre-training the encoding end in the language model according to the text features and a preset training task.

[0091] The server may input the identifier sequence corresponding to the first sample text into the language model to obtain text features corresponding to the identifier sequence output by the language model, and then pre-train the coding segment in the language model according to the text features and a preset training task.

[0092] In one or more embodiments of the present specification, the language model includes an encoding end, and the server can input the identifier sequence into the encoding end of the language model to obtain text features output by the encoding end, and then the server can train the encoding end according to the text features and preset training tasks.

[0093] like Figure 2 As shown, Figure 2 A structural diagram of a language model provided in the specification of this application, it can be seen that the language model also includes an embedding layer, or a token embedding layer, and the encoding end of the language model can be a multi-layer TransformerEncoder. When the identifier sequence is input into the language model, the server first inputs the identifier sequence into the embedding layer to obtain the embedding features corresponding to the identifier sequence, and then inputs the embedded features into the encoding end to obtain the text features corresponding to the identifier sequence. In this specification, the embedding layer can be used to convert each identifier in the identifier sequence corresponding to the first sample text into a vector representation of a fixed length, and then the embedding matrix corresponding to the identifier sequence can be obtained through the embedding layer, and the embedding matrix is ​​the aforementioned embedding feature. Then, according to the text features and the preset training tasks, the encoding end in the language model is pre-trained, and the encoding end and the embedding layer in the language model can be pre-trained.

[0094] based on Figure 1The pre-training method of the language model shown processes each field in the structured text, replaces each field with an identifier, and then uses the identifier sequence corresponding to the structured text to train the language model, so that the trained language model can learn the correlation and potential relationship of the features in the structured text, thereby improving the accuracy of the language model.

[0095] In one or more embodiments of the present specification, in the above step S102, when extracting each field in the first sample text, the attribute value corresponding to the first sample text may be normalized according to the attribute and attribute value corresponding to the first sample text to obtain the normalized first sample text, and then each field in the normalized first sample text may be extracted. Normalizing the attribute value may eliminate abnormal values, etc., thereby improving the subsequent training efficiency of the language model and improving the accuracy of the trained language model.

[0096] In addition, in this specification, the preset training task may be a mask learning task. The language model may also include a decoding end, such as Figure 3 As shown, Figure 3 A structural diagram of a language model provided in the specification of the present application. When inputting an identifier sequence into the language model, the server may first process the identifier sequence through a mask, input the processed identifier sequence into the language model, and the language model may output text features corresponding to the processed identifier sequence. The server may then input the text features corresponding to the processed identifier sequence into the decoding end, and the decoding end may output a predicted text, which is obtained by restoring the processed identifier sequence based on the text features corresponding to the processed identifier sequence. The server may train the encoding end of the language model with the goal of minimizing the difference between the predicted text and the identifier text sequence.

[0097] Using the above example, if the identifier sequence corresponding to the first sample text is "User A az", then the identifier sequence after masking can be "User A[mask]z". Then "User A[mask]z" can be input into the encoding end to obtain text features, and the text features can be input into the decoding end. The decoding end can output the predicted text after restoring the identifier sequence after masking. Assuming that the predicted text is "User A bz", the server can train the encoding end of the language model with the goal of minimizing the difference between "User A bz" and "User Aa z". In other words, the server can determine the loss based on the difference between "User Ab z" and "User Aa z", that is, the server can determine the loss based on the predicted text and the identifier text sequence, and train the encoding end of the language model based on the loss.

[0098] It should be noted that, in one or more embodiments of the present specification, the parameter adjustment of the language model is for the encoding end, and there is no need to adjust the parameters of the decoding end.

[0099] In one or more embodiments of the present specification, during the masking process, tokens in the identifier text sequence may be masked with a certain probability, or tokens in the identifier text sequence may be replaced with other tokens with a certain probability, and so on.

[0100] Furthermore, the pre-training method of the above-mentioned language model uses a mask learning task, which requires obtaining the output text corresponding to the fusion features extracted by the encoding end, so a decoding end is provided in the language model so that the decoding end processes the fusion features to obtain the output text. However, in the absence of a decoding end, in order to enable the language model to still be pre-trained, the training task can be a contrast learning task.

[0101] Specifically, in one or more embodiments of the present specification, when the identifier text sequence is input into the language model in the above step S108, a derivative sequence related to the identifier text sequence may also be determined for each identifier text sequence.

[0102] Among them, the semantics of the identifier text sequence and the semantics of the derived sequence are similar. When determining the derived sequence related to the identifier text sequence, the parallel corpus text sequence of the identifier text sequence can be determined, and the parallel corpus text sequence can be used as the derived sequence of the identifier text sequence. Using the above Table 1, the Chinese "User A" can be replaced with the English "user A". Or stop words are inserted into the identifier text sequence, and the sample text after the stop words are inserted is used as the derived sequence. The stop words can be punctuation marks. Synonym replacement and so on can also be performed, as long as a derivative sequence with similar semantics to the identifier text sequence can be determined, and the specific method for determining the derivative sequence is not limited in this specification.

[0103] Then, the server can use the identifier text sequence and the derivative sequence of the identifier text sequence as positive samples, and use other identifier text sequences except the identifier text sequence as negative samples, and then input the positive samples and negative samples into the encoding end of the language model respectively, so as to extract features from the positive samples to obtain text features corresponding to the positive samples, and extract features from the negative samples to obtain text features corresponding to the negative samples. Then, the server can train the encoding end of the language model with the goal of maximizing the similarity between the text features corresponding to each positive sample and minimizing the similarity between the text features corresponding to the positive sample and the text features corresponding to the negative sample.

[0104] Furthermore, in one or more embodiments of the present specification, for the pre-trained language model, the server can also determine the target business to which it is to be applied, that is, the specific scenario in which it is applied, for example: the target business to which the pre-trained language model is applied is to perform sentiment analysis on the evaluation statements of users after shopping to evaluate whether the item is popular, or the target business is product recommendation, etc. Then, the server can obtain the business sample text and the annotations corresponding to the business sample text according to the target business. Then, according to the business sample text and the annotations corresponding to the business sample text, the pre-trained language model is fine-tuned to obtain the trained language model, so that the trained language model can execute the target business.

[0105] The following description will be made by taking the target business of product recommendation as an example.

[0106] The server can then obtain product information of the product and user information of the user, and use the product information and user information as the second sample text. The server can also obtain a label corresponding to the second sample text, which indicates whether the product is recommended to the user. The pre-trained language model can then be fine-tuned based on the second sample text and the label corresponding to the second sample text to obtain a trained language model.

[0107] When fine-tuning the language model, the server may input the second sample text into the pre-trained language model to obtain an output result, determine the loss based on the output result and the annotation corresponding to the second sample text, and adjust the parameters of the pre-trained language model based on the loss.

[0108] It should be noted that when fine-tuning the language model, or in other words, when adjusting the parameters of the pre-trained language model based on the loss determined based on the output results and the annotations corresponding to the second sample text, only the parameters of the decoding end can be adjusted, that is, both the parameters of the encoding end and the parameters of the decoding end can be adjusted.

[0109] In one or more embodiments of the present specification, when adjusting the parameters of the encoding end and the decoding end in the pre-trained language model according to the loss, the adjustments can be made according to certain weights. Since the encoding end has learned the feature relationship between structured text sequences to a certain extent, and the training of the decoding end is to be performed according to the target business to which the language model is specifically applied, when adjusting the parameters according to the target business to which the language model is specifically applied, the weight of the adjustment of the parameters of the encoding end may not be greater than the weight of the adjustment of the parameters of the decoding end.

[0110] It should be noted that, in one or more embodiments of this specification, whether in the above-mentioned language model pre-training method or in the above-mentioned pre-trained language model training method, this specification does not limit when to determine that the (pre) training of the language model is finished. For example, when the number of (pre) training iterations reaches a preset threshold, it is determined that the (pre) training of the language model is finished, or when the determined loss is less than a preset value, it is determined that the (pre) training of the language model is finished.

[0111] Based on the language model pre-training method described above, the embodiment of this specification also provides a schematic diagram of a language model pre-training device, such as Figure 4 shown.

[0112] Figure 4 A schematic diagram of a language model pre-training device provided in an embodiment of this specification, the device comprising:

[0113] The acquisition module 400 is used to acquire a first sample text; the first sample text is a structured text;

[0114] An extraction module 402, configured to extract each field in the first sample text;

[0115] A first determination module 404 is used to determine, for each extracted field, an identifier corresponding to the field according to the attribute and attribute value of the field;

[0116] A second determination module 406 is used to obtain an identifier sequence corresponding to the first sample text according to the determined identifiers corresponding to the fields;

[0117] An input module 408, configured to input the identifier sequence into the language model to obtain text features corresponding to the identifier sequence;

[0118] The first training module 410 is used to pre-train the encoding end in the language model according to the text features and the preset training tasks.

[0119] Optionally, the language model further includes: an embedding layer;

[0120] The input module 408 is specifically used to input the identifier sequence into the embedding layer to obtain the embedding features corresponding to the identifier sequence; and input the embedding features into the encoding end to obtain the text features corresponding to the identifier sequence.

[0121] Optionally, the first determination module 404 is specifically used to determine, based on the attributes of the field, a set of identifiers corresponding to the field, each identifier in the set of identifiers having a preset correspondence with each attribute value range of the attribute; and to determine, based on the attribute value of the field, in the set of identifiers, an identifier corresponding to the field.

[0122] Optionally, the language model further includes: a decoding end;

[0123] The input module 408 is specifically used to process the identifier sequence through masking, and input the identifier sequence after masking into the language model;

[0124] The first training module 410 is specifically used to input the text features into the decoding end to obtain the predicted text output by the decoding end, where the predicted text is obtained by the decoding end restoring the identifier sequence after masking based on the text features; and training the encoding end with the goal of minimizing the difference between the predicted text and the identifier text sequence.

[0125] Optionally, the extraction module 402 is specifically used to normalize the attribute values ​​corresponding to the first sample text according to the attributes and attribute values ​​corresponding to the first sample text to obtain the normalized first sample text; and extract each field in the normalized first sample text.

[0126] Optionally, the device further includes a second training module 412;

[0127] The second training module 412 is specifically used to obtain product information of the product and user information of the user, and use the product information and the user information as the second sample text; and obtain the annotation corresponding to the second sample text, the annotation indicating whether the product is recommended to the user; and fine-tune the pre-trained language model according to the second sample text and the annotation corresponding to the second sample text to obtain a trained language model.

[0128] Optionally, the second training module 412 is specifically used to input the second sample text into the pre-trained language model to obtain an output result; determine the loss based on the output result and the annotation corresponding to the second sample text; and adjust the parameters of the pre-trained language model based on the loss.

[0129] The embodiments of this specification also provide a computer-readable storage medium, which stores a computer program. The computer program can be used to execute the language model pre-training method described above.

[0130] Based on the language model pre-training method described above, this specification also proposes Figure 5 The schematic structure diagram of the electronic device shown in FIG. Figure 5 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the language model pre-training method described above.

[0131] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the executor of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0132] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0133] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.

[0134] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0135] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0136] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0137] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart 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 produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0138] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0139] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0140] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0141] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0142] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0143] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0144] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0145] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0146] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0147] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.

Claims

1. A pre-training method for a language model, a language model include: Encoding end; The method comprises: Obtaining a first sample text; the first sample text is a structured text; Extracting each field in the first sample text; For each extracted field, determine the identifier corresponding to the field according to the attributes and attribute values ​​of the field; Obtaining an identifier sequence corresponding to the first sample text according to the determined identifiers corresponding to the fields; Inputting the identifier sequence into the language model to obtain text features corresponding to the identifier sequence; The encoding end in the language model is pre-trained according to the text features and the preset training tasks.

2. The method according to claim 1, wherein the language model further include: Embedding layer; Inputting the identifier sequence into the language model to obtain text features corresponding to the identifier sequence specifically includes: Inputting the identifier sequence into the embedding layer to obtain embedding features corresponding to the identifier sequence; The embedded features are input into the encoding end to obtain text features corresponding to the identifier sequence.

3. The method according to claim 1, determining the identifier corresponding to the field according to the attribute and attribute value of the field, specifically include: According to the attribute of the field, determine an identifier set corresponding to the field, each identifier in the identifier set having a preset corresponding relationship with each attribute value range of the attribute; According to the attribute value of the field, an identifier corresponding to the field is determined in the identifier set.

4. The method according to claim 1, wherein the language model further comprises include: Decoding end; Inputting the identifier sequence into the language model specifically includes: Processing the identifier sequence by masking, and inputting the masked identifier sequence into the language model; According to the text features and the preset training tasks, the encoding end in the language model is pre-trained, specifically including: Inputting the text feature into the decoding end to obtain a predicted text output by the decoding end, wherein the predicted text is obtained by restoring the identifier sequence after the masking process by the decoding end based on the text feature; The encoding end is trained with the goal of minimizing the difference between the predicted text and the identifier text sequence.

5. The method according to claim 1, extracting each field in the first sample text, specifically include: According to the attributes and attribute values ​​corresponding to the first sample text, normalizing the attribute values ​​corresponding to the first sample text to obtain a normalized first sample text; Extract each field in the first sample text after the normalization process.

6. The method according to claim 1, further comprising: include: Acquire product information of a product and user information of a user, and use the product information and the user information as second sample text; and obtaining a label corresponding to the second sample text, the label indicating whether the product is recommended to the user; The pre-trained language model is fine-tuned according to the second sample text and the annotation corresponding to the second sample text to obtain a trained language model.

7. The method according to claim 6, further comprising fine-tuning the pre-trained language model according to the second sample text and the annotation corresponding to the second sample text, specifically: include: Inputting the second sample text into the pre-trained language model to obtain an output result; Determining a loss according to the output result and the annotation corresponding to the second sample text; According to the loss, the parameters of the language model obtained by pre-training are adjusted.

8. A pre-training device for a language model, a language model include: Encoding end; The device specifically comprises: An acquisition module, used for acquiring a first sample text; the first sample text is a structured text; An extraction module, used for extracting each field in the first sample text; A first determination module is used to determine, for each extracted field, an identifier corresponding to the field according to the attribute and attribute value of the field; A second determination module, configured to obtain an identifier sequence corresponding to the first sample text according to the determined identifiers corresponding to the fields; An input module, used for inputting the identifier sequence into the language model to obtain text features corresponding to the identifier sequence; The first training module is used to pre-train the encoding end in the language model according to the text features and the preset training tasks.

9. A computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the program.

Citation Information

Cited By

  • Model training and page detection method and device, medium and equipment

    CN119046174A

  • Data processing method, device and equipment

    CN119312374A

  • Data processing method, device and equipment

    CN119312374B